Skip to content

Commit 5a1205b

Browse files
authored
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)
Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before the interpreter is deleted.
1 parent 26e5c6e commit 5a1205b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/pylifecycle.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,12 @@ Py_FinalizeEx(void)
21192119
}
21202120
#endif /* Py_TRACE_REFS */
21212121

2122+
#ifdef WITH_PYMALLOC
2123+
if (malloc_stats) {
2124+
_PyObject_DebugMallocStats(stderr);
2125+
}
2126+
#endif
2127+
21222128
finalize_interp_delete(tstate->interp);
21232129

21242130
#ifdef Py_REF_DEBUG
@@ -2129,12 +2135,6 @@ Py_FinalizeEx(void)
21292135
#endif
21302136
_Py_FinalizeAllocatedBlocks(runtime);
21312137

2132-
#ifdef WITH_PYMALLOC
2133-
if (malloc_stats) {
2134-
_PyObject_DebugMallocStats(stderr);
2135-
}
2136-
#endif
2137-
21382138
call_ll_exitfuncs(runtime);
21392139

21402140
_PyRuntime_Finalize();

0 commit comments

Comments
 (0)