Skip to content

Commit e3e7607

Browse files
authored
[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 5a1205b)
1 parent 3bf7a50 commit e3e7607

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Python/pylifecycle.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,13 @@ Py_FinalizeEx(void)
19691969
// XXX Ensure finalizer errors are handled properly.
19701970

19711971
finalize_interp_clear(tstate);
1972+
1973+
#ifdef WITH_PYMALLOC
1974+
if (malloc_stats) {
1975+
_PyObject_DebugMallocStats(stderr);
1976+
}
1977+
#endif
1978+
19721979
finalize_interp_delete(tstate->interp);
19731980

19741981
#ifdef Py_REF_DEBUG
@@ -1994,11 +2001,6 @@ Py_FinalizeEx(void)
19942001
fclose(dump_refs_fp);
19952002
}
19962003
#endif /* Py_TRACE_REFS */
1997-
#ifdef WITH_PYMALLOC
1998-
if (malloc_stats) {
1999-
_PyObject_DebugMallocStats(stderr);
2000-
}
2001-
#endif
20022004

20032005
call_ll_exitfuncs(runtime);
20042006

0 commit comments

Comments
 (0)