Skip to content

Commit

Permalink
[3.12] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021) (#12…
Browse files Browse the repository at this point in the history
…0023)

gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)

Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before
the interpreter is deleted.

(cherry picked from commit 5a1205b)
  • Loading branch information
vstinner committed Jun 4, 2024
1 parent 3bf7a50 commit e3e7607
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,13 @@ Py_FinalizeEx(void)
// XXX Ensure finalizer errors are handled properly.

finalize_interp_clear(tstate);

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

finalize_interp_delete(tstate->interp);

#ifdef Py_REF_DEBUG
Expand All @@ -1994,11 +2001,6 @@ Py_FinalizeEx(void)
fclose(dump_refs_fp);
}
#endif /* Py_TRACE_REFS */
#ifdef WITH_PYMALLOC
if (malloc_stats) {
_PyObject_DebugMallocStats(stderr);
}
#endif

call_ll_exitfuncs(runtime);

Expand Down

0 comments on commit e3e7607

Please sign in to comment.