mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
d207c7cd5a
commit
e3ad6ca56f
8 changed files with 226 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue