classification
Title: Interpreter seems to leak references after finalization
Type: resource usage Stage: test needed
Components: Interpreter Core Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, amaury.forgeotdarc, kylotan, santa4nt, tlesher, ysj.ray
Priority: normal Keywords:

Created on 2007-01-15 10:26 by kylotan, last changed 2011-03-31 11:49 by tlesher.

Messages (4)
msg61054 - (view) Author: B Sizer (kylotan) Date: 2007-01-15 10:26
This C code:

#include <Python.h>
int main(int argc, char *argv[])
{
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
    Py_Initialize(); Py_Finalize();
}

Produces this output:
[7438 refs]
[7499 refs]
[7550 refs]
[7601 refs]
[7652 refs]
[7703 refs]
[7754 refs]

A similar program configured to call the Py_Initialize()/Py_Finalize() 1000 times ends up with:
...
[58295 refs]
[58346 refs]
[58397 refs]

This is with a fresh debug build of Python 2.5.0 on Windows XP, using Visual C++ 2003.
msg110895 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-07-20 13:41
Does the title of this issue accurately reflect the current status of the Python interpreter?
msg111024 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-21 09:20
Yes, some objects are not cleaned in finalization.
This is not a problem in usual cases though, when the interpreter is
started only once.
msg130729 - (view) Author: ysj.ray (ysj.ray) Date: 2011-03-13 07:12
> Does the title of this issue accurately reflect the current status of the Python interpreter?

Yes, here is the running result on current 3.3 latest code:
[37182 refs]
[39415 refs]
[41607 refs]
[43799 refs]
[45991 refs]
[48183 refs]
[50375 refs]


This seems to be a known bug that Py_Finalize() doesn't free all objects according doc http://docs.python.org/dev/c-api/init.html?highlight=py_finalize#Py_Finalize
History
Date User Action Args
2011-03-31 11:49:57tleshersetnosy: + tlesher
2011-03-13 09:18:08santa4ntsetnosy: + santa4nt
2011-03-13 07:12:36ysj.raysetnosy: amaury.forgeotdarc, kylotan, ysj.ray, BreamoreBoy
messages: + msg130729
2011-02-14 03:07:28ysj.raysetnosy: + ysj.ray
2010-07-21 10:21:13amaury.forgeotdarclinkissue8258 superseder
2010-07-21 09:20:21amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg111024
2010-07-20 13:41:15BreamoreBoysetnosy: + BreamoreBoy

messages: + msg110895
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0
2009-03-30 19:04:21ajaksu2setstage: test needed
type: resource usage
versions: + Python 2.6, Python 3.0, - Python 2.5
2007-01-15 10:26:05kylotancreate