Skip to content

Commit

Permalink
[3.13] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (GH-120021) (#…
Browse files Browse the repository at this point in the history
…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 <vstinner@python.org>
  • Loading branch information
miss-islington and vstinner committed Jun 4, 2024
1 parent 1177897 commit 6e67fd5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,12 @@ Py_FinalizeEx(void)
}
#endif /* Py_TRACE_REFS */

#ifdef WITH_PYMALLOC
if (malloc_stats) {
_PyObject_DebugMallocStats(stderr);
}
#endif

finalize_interp_delete(tstate->interp);

#ifdef Py_REF_DEBUG
Expand All @@ -2129,12 +2135,6 @@ Py_FinalizeEx(void)
#endif
_Py_FinalizeAllocatedBlocks(runtime);

#ifdef WITH_PYMALLOC
if (malloc_stats) {
_PyObject_DebugMallocStats(stderr);
}
#endif

call_ll_exitfuncs(runtime);

_PyRuntime_Finalize();
Expand Down

0 comments on commit 6e67fd5

Please sign in to comment.