Python leaks in cyclic garbage collection

moerchendiser2k3 googler.1.webmaster at spamgourmet.com
Fri Feb 18 23:10:43 EST 2011


Hi, I have some problems with Python and the garbage collection. In
the following piece of code I create a simple gargabe collection but I
am still wondering why the finalizers are never called - at least on
exit of Py they should be called somehow. What do I miss here? I know,
there is no deterministic way how to resolve this though.

class Foo():

    def __init__(self):
        self.b=Bar(self)

    def __del__(self):
        print "Free Foo"

class Bar():
    def __init__(self, f):
        self.f=f

    def __del__(self):
        print "Free Bar"

f=Foo()
print f



More information about the Python-list mailing list