summaryrefslogtreecommitdiffstats
path: root/Python/gc_gil.c
blob: c8ca397be7ae585bc0e5e474e07f4e8f35eafac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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);
    _PyDict_ClearFreeList(interp);
    _PyAsyncGen_ClearFreeLists(interp);
    _PyContext_ClearFreeList(interp);

    _Py_ClearFreeLists(&interp->freelist_state, 0);
}

#endif