summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-03-21 17:46:09 (GMT)
committerGitHub <noreply@github.com>2023-03-21 17:46:09 (GMT)
commit743687434c5baf01c266320b34c7a828726702a6 (patch)
tree6d26f4fcb5aaa2b606b433aecad939e9f36734f9 /Python/pystate.c
parent4bb1dd3c5c14338c9d9cea5988431c858b3b76e0 (diff)
downloadcpython-743687434c5baf01c266320b34c7a828726702a6.zip
cpython-743687434c5baf01c266320b34c7a828726702a6.tar.gz
cpython-743687434c5baf01c266320b34c7a828726702a6.tar.bz2
gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)
Moving it valuable with a per-interpreter GIL. However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter. This becomes more important as we move the obmalloc state to PyInterpreterState. https://github.com/python/cpython/issues/102304
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 60adb54..b17efdb 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -483,8 +483,8 @@ void
_PyRuntimeState_Fini(_PyRuntimeState *runtime)
{
#ifdef Py_REF_DEBUG
- /* The reftotal is cleared by _Py_FinalizeRefTotal(). */
- assert(runtime->object_state.reftotal == 0);
+ /* The count is cleared by _Py_FinalizeRefTotal(). */
+ assert(runtime->object_state.interpreter_leaks == 0);
#endif
if (gilstate_tss_initialized(runtime)) {
@@ -904,6 +904,12 @@ PyInterpreterState_Delete(PyInterpreterState *interp)
_PyEval_FiniState(&interp->ceval);
+#ifdef Py_REF_DEBUG
+ // XXX This call should be done at the end of clear_interpreter(),
+ // but currently some objects get decref'ed after that.
+ _PyInterpreterState_FinalizeRefTotal(interp);
+#endif
+
HEAD_LOCK(runtime);
PyInterpreterState **p;
for (p = &interpreters->head; ; p = &(*p)->next) {