gc.DEBUG_LEAK and gc.garbage

Skip Montanaro skip at pobox.com
Tue Apr 19 14:00:17 EDT 2005


    Cesar> I have set the DEBUG_LEAK flag with the GC and in the program
    Cesar> cycle printed the length of the garbage list. Is this enough to
    Cesar> determine if there is a leak in the python code? (the value
    Cesar> rises).

That suggests to me that you have objects with __del__ methods that are
involved in cycles.  Get rid of the __del__ methods or figure out some way
to break the cycles.

    Cesar> Finally, in this group I have seen a reference to an article in
    Cesar> which they had the look to gc.garbage after calling explicitally
    Cesar> to gc.collect(). is this necessary?

Generally, no, but if you want to make sure the collector has run when you
want to look at gc.garbage it's convenient to call gc.collect() first.

Skip



More information about the Python-list mailing list