mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-122697: Fix free-threading memory leaks at shutdown (#122703)
We were not properly accounting for interpreter memory leaks at shutdown and had two sources of leaks: * Objects that use deferred reference counting and were reachable via static types outlive the final GC. We now disable deferred reference counting on all objects if we are calling the GC due to interpreter shutdown. * `_PyMem_FreeDelayed` did not properly check for interpreter shutdown so we had some memory blocks that were enqueued to be freed, but never actually freed. * `_PyType_FinalizeIdPool` wasn't called at interpreter shutdown.
This commit is contained in:
parent
833eb106f5
commit
2d9d3a9f53
5 changed files with 27 additions and 4 deletions
|
@ -20,7 +20,7 @@
|
|||
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
|
||||
#include "pycore_sysmodule.h" // _PySys_Audit()
|
||||
#include "pycore_obmalloc.h" // _PyMem_obmalloc_state_on_heap()
|
||||
#include "pycore_typeid.h" // _PyType_FinalizeIdPool
|
||||
#include "pycore_typeid.h" // _PyType_FinalizeThreadLocalRefcounts()
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
CAUTION
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue