mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)
This commit is contained in:
parent
cdca0ce0ad
commit
57bdc6c30d
17 changed files with 171 additions and 50 deletions
23
Python/gc_gil.c
Normal file
23
Python/gc_gil.c
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue