summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/gc_gil.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/python3/Python/gc_gil.c')
-rw-r--r--contrib/tools/python3/Python/gc_gil.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/tools/python3/Python/gc_gil.c b/contrib/tools/python3/Python/gc_gil.c
new file mode 100644
index 00000000000..48646c7af86
--- /dev/null
+++ b/contrib/tools/python3/Python/gc_gil.c
@@ -0,0 +1,17 @@
+#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)
+{
+ _PyObject_ClearFreeLists(&interp->object_state.freelists, 0);
+}
+
+#endif