summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-02-20 18:04:37 (GMT)
committerGitHub <noreply@github.com>2024-02-20 18:04:37 (GMT)
commite3ad6ca56f9b49db0694f432a870f907a8039f79 (patch)
treee04a42ed027f6595dec9efe051104d487cfb03a8 /Python/pylifecycle.c
parentd207c7cd5a8c0d3e5f6c5eb947243e4afcd718b0 (diff)
downloadcpython-e3ad6ca56f9b49db0694f432a870f907a8039f79.zip
cpython-e3ad6ca56f9b49db0694f432a870f907a8039f79.tar.gz
cpython-e3ad6ca56f9b49db0694f432a870f907a8039f79.tar.bz2
gh-115103: Implement delayed free mechanism for free-threaded builds (#115367)
This adds `_PyMem_FreeDelayed()` and supporting functions. The `_PyMem_FreeDelayed()` function frees memory with the same allocator as `PyMem_Free()`, but after some delay to ensure that concurrent lock-free readers have finished.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 656d821..0448734 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1837,6 +1837,9 @@ finalize_interp_clear(PyThreadState *tstate)
finalize_interp_types(tstate->interp);
+ /* Free any delayed free requests immediately */
+ _PyMem_FiniDelayed(tstate->interp);
+
/* finalize_interp_types may allocate Python objects so we may need to
abandon mimalloc segments again */
_PyThreadState_ClearMimallocHeaps(tstate);