Skip to content

Commit 6e67fd5

Browse files
[3.13] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (GH-120021) (#120022)
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (GH-120021) Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before the interpreter is deleted. (cherry picked from commit 5a1205b) Co-authored-by: Victor Stinner <[email protected]>
1 parent 1177897 commit 6e67fd5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Python/pylifecycle.c

+6-6
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)