[issue1635741] Py_Finalize() doesn't clear all Python objects at exit
STINNER Victor
report at bugs.python.org
Tue Oct 22 20:11:30 EDT 2019
STINNER Victor <vstinner at python.org> added the comment:
I tested on the master branch of Python:
---
#include <Python.h>
void func()
{
Py_Initialize(); Py_Finalize();
Py_ssize_t cnt = _Py_GetRefTotal();
printf("sys.gettotalrefcount(): %zd\n", cnt);
}
int main(int argc, char *argv[])
{
Py_SetProgramName(L"./_testembed");
for (int i=0; i < 10; i++) {
func();
}
}
---
Each iteration leaks around 5,000 Python objects:
---
sys.gettotalrefcount(): 15113
sys.gettotalrefcount(): 19527
sys.gettotalrefcount(): 23941
sys.gettotalrefcount(): 28355
sys.gettotalrefcount(): 32769
sys.gettotalrefcount(): 37183
sys.gettotalrefcount(): 41597
sys.gettotalrefcount(): 46011
sys.gettotalrefcount(): 50425
sys.gettotalrefcount(): 54839
---
----------
nosy: +vstinner
title: Interpreter seems to leak references after finalization -> Py_Finalize() doesn't clear all Python objects at exit
versions: +Python 3.9 -Python 2.7, Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue1635741>
_______________________________________
More information about the Python-bugs-list
mailing list