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
This commit is contained in:
Eric Snow 2023-03-21 11:46:09 -06:00 committed by GitHub
parent 4bb1dd3c5c
commit 743687434c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 117 additions and 40 deletions

View file

@ -802,6 +802,11 @@ pycore_interp_init(PyThreadState *tstate)
PyStatus status;
PyObject *sysmod = NULL;
// This is a temporary fix until we have immortal objects.
// (See _PyType_InitCache() in typeobject.c.)
extern void _PyType_FixCacheRefcounts(void);
_PyType_FixCacheRefcounts();
// Create singletons before the first PyType_Ready() call, since
// PyType_Ready() uses singletons like the Unicode empty string (tp_doc)
// and the empty tuple singletons (tp_bases).