Python leaks in cyclic garbage collection

n00m n00m at narod.ru
Mon Feb 21 10:10:48 CET 2011


> Wild guess:
> maybe when python exits they are called but sys.stdout has already been closed and nothing gets written on it anymore.

Certainly NOT.


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.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b.f
print f.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b.f.b



*********Console output:***********

<__main__.Foo instance at 0x00AF7328>
<__main__.Bar instance at 0x00AF7350>

D:\v3>




More information about the Python-list mailing list