diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-04-14-15-22-30.gh-issue-132519.Ngn0__.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-04-14-15-22-30.gh-issue-132519.Ngn0__.rst new file mode 100644 index 00000000000000..f8c1bb77770225 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-04-14-15-22-30.gh-issue-132519.Ngn0__.rst @@ -0,0 +1 @@ +Fix excessive memory usage when freeing large blocks via QSBR in :term:`free-threaded ` build. diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c index a455779a6598e9..8ec0f0f677a517 100644 --- a/Python/ceval_gil.c +++ b/Python/ceval_gil.c @@ -1350,6 +1350,9 @@ _Py_HandlePending(PyThreadState *tstate) _Py_unset_eval_breaker_bit(tstate, _PY_EVAL_EXPLICIT_MERGE_BIT); _Py_brc_merge_refcounts(tstate); } + + /* Keep memory usage down if QSBR freeing large blocks. */ + _PyMem_ProcessDelayed(tstate); #endif /* GC scheduled to run */