[3.12] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021) (#120023)

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

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

(cherry picked from commit 5a1205b641)
This commit is contained in:
Victor Stinner 2024-06-04 11:58:49 +02:00 committed by GitHub
parent 3bf7a5079c
commit e3e7607167
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
@ -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);