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:
Sam Gross 2024-02-20 13:04:37 -05:00 committed by GitHub
parent d207c7cd5a
commit e3ad6ca56f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 226 additions and 0 deletions

View file

@ -176,6 +176,7 @@ extern PyTypeObject _PyExc_MemoryError;
}, \
.dtoa = _dtoa_state_INIT(&(INTERP)), \
.dict_state = _dict_state_INIT, \
.mem_free_queue = _Py_mem_free_queue_INIT(INTERP.mem_free_queue), \
.func_state = { \
.next_version = 1, \
}, \