[Python-bugs-list] [Bug #128040] memory leak with multiple Py_Initialize/Py_Finalize calls

noreply@sourceforge.net noreply@sourceforge.net
Tue, 09 Jan 2001 17:11:50 -0800


Bug #128040, was updated on 2001-Jan-08 07:00
Here is a current snapshot of the bug.

Project: Python
Category: Python Interpreter Core
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: pbmtl
Assigned to : mhammond
Summary: memory leak with multiple Py_Initialize/Py_Finalize calls

Details: I run script that use the win32 extension embedded in a server. 
When I call the Py_Finalize method, the memory is not free completely. 
Each time I run a script, my server uses more and more memory.
I think the Patch #101713 talk about this problem.  It seems that python
have problem handling multiple Py_Initialize and Py_Finalise when extension
are used.

Follow-Ups:

Date: 2001-Jan-09 17:11
By: mhammond

Comment:
I dont believe this is Windows specific, nor specific to the Win32
extensions.  I can confirm that Python does leak with multiple Init/Terms,
as I had to change the COM extensions to only initialize once (and hence
never finalize).  It is definitely related to the referenced patch
(#101713)

This has been raised before, but there doesnt appear much enthusiasm for a
fix.  As far as I can tell, it would involve having Py_Finalize() correctly
release _all_ memory allocated by Py_Initialize().  However, I have seen
numerous people state that "one off" allocations that are not freed are not
worth finding and freeing - however, if this bug wants a fix, then we must
track them all down.

I further note that the problem is not only in the Python core, but in
extension modules.  Modules need a reliable way to be told that Python is
finalizing so they can free their own "one off" allocations.  Various hacks
have been proposed for this (eg, rely on ref-count semantics to ensure that
a special object is destroyed as the module dict is cleared) but nothing
"reasonable" has been proposed.

Really not sure what I can do here.  I am willing to do my bit in patching
up the leaks, but would want a (fuzzy) commitment from python-dev that I
wouldnt be doing it alone, and that it is seen as important.

I have updated the bug description and platform appropriately, but haven't
reallocated a new person.
-------------------------------------------------------

Date: 2001-Jan-09 14:38
By: tim_one

Comment:
Reassigned to MarkH.  Mark, sound familiar?

-------------------------------------------------------

Date: 2001-Jan-08 18:02
By: gvanrossum

Comment:
Assigned to Tim.  First task would be to request needed infromation from
submitter.

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=128040&group_id=5470