gc.garbage

7stud dolgun at excite.com
Thu Aug 30 05:46:13 EDT 2007


gc.garbage returns an empty list even though the command:

 gc.set_debug(gc.DEBUG_LEAK)

produces the following output:

gc: uncollectable <Dog 0x56e10>
gc: uncollectable <Cat 0x56e30>
gc: uncollectable <dict 0x58270>
gc: uncollectable <dict 0x43e40>

I expected all those objects to be in the list returned by
gc.garbage.  Here's the code:

import gc

class Cat(object):
    def __del__():
        pass

class Dog(object):
    def __del__():
        pass

def some_func():
    the_dog = Dog()
    the_cat = Cat()
    the_dog.cat = the_cat
    the_cat.dog = the_dog

some_func()

gc.set_debug(gc.DEBUG_LEAK)
print gc.garbage

--output:--
[]
gc: uncollectable <Dog 0x56e10>
gc: uncollectable <Cat 0x56e30>
gc: uncollectable <dict 0x58270>
gc: uncollectable <dict 0x43e40>




More information about the Python-list mailing list