diff options
author | Donghee Na <donghee.na@python.org> | 2024-01-09 23:04:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 23:04:41 (GMT) |
commit | 57bdc6c30d2665c2760ff5a88487e57c8b3c397a (patch) | |
tree | de5a4efb2a25eac14672c6a538ca6e50ae7ed582 /Python/gc_gil.c | |
parent | cdca0ce0ad47604b7007229415817a7a152f7f9a (diff) | |
download | cpython-57bdc6c30d2665c2760ff5a88487e57c8b3c397a.zip cpython-57bdc6c30d2665c2760ff5a88487e57c8b3c397a.tar.gz cpython-57bdc6c30d2665c2760ff5a88487e57c8b3c397a.tar.bz2 |
gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)
Diffstat (limited to 'Python/gc_gil.c')
-rw-r--r-- | Python/gc_gil.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Python/gc_gil.c b/Python/gc_gil.c new file mode 100644 index 0000000..b0961cd --- /dev/null +++ b/Python/gc_gil.c @@ -0,0 +1,23 @@ +#include "Python.h" +#include "pycore_pystate.h" // _Py_ClearFreeLists() + +#ifndef Py_GIL_DISABLED + +/* Clear all free lists + * All free lists are cleared during the collection of the highest generation. + * Allocated items in the free list may keep a pymalloc arena occupied. + * Clearing the free lists may give back memory to the OS earlier. + */ +void +_PyGC_ClearAllFreeLists(PyInterpreterState *interp) +{ + _PyTuple_ClearFreeList(interp); + _PyFloat_ClearFreeList(interp); + _PyDict_ClearFreeList(interp); + _PyAsyncGen_ClearFreeLists(interp); + _PyContext_ClearFreeList(interp); + + _Py_ClearFreeLists(&interp->freelist_state, 0); +} + +#endif |