[Python-Dev] Py_Finalize does not release all memory, not even closely

"Martin v. Löwis" martin at v.loewis.de
Sun Apr 16 08:50:25 CEST 2006


Tim Peters wrote:
> Because new-style classes create cycles that Py_Finalize() doesn't
> clean up, it may make analysis easier to stick a PyGC_Collect() call
> (or two!  repeat until it returns 0) inside the loop now.

I'm shy to do this: the comment in Py_Finalize suggests that things
will break if there is a "late" garbage collection.

> There is no way at present, short of editing the source for
> Py_Finalize and recompiling.  Presumably this is something that should
> be addressed in the module initialization/finalization PEP, right? 

Indeed.

>> This totals to 360, which is for some reason higher than the numbers
>> I get when counting the objects on the global list of objects.
> 
> How much higher?

Well, I counted an increase of 156 objects on the "all objects"
list, and an increase of 360 according to the COUNT_ALLOCS numbers.
The first number was without COUNT_ALLOCS being defined, though.

Anyway, thanks for your comments. I'll try to look at this from
time to time, maybe I can resolve some of the leaks.

Regards,
Martin



More information about the Python-Dev mailing list