Python method reference kills garbage collection?
Just van Rossum
just at xs4all.nl
Thu Feb 7 06:12:46 EST 2002
Troels Walsted Hansen wrote:
> Consider the following program. What is so special about references to the
> object's own methods that cause the object to never be garbage collected? Is
> this a cyclic reference problem, and if so why doesn't the cycle detector
> (--with-cycle-gc) cure the problem?
>
> class a:
> def __init__(self):
> self.f = self.f1
> def __del__(self):
> print "this is never printed"
> def f1(self):
> pass
> b=a()
> b=a()
The cycle collector doesn't collect objects of classes with __del__ methods.
(See http://www.python.org/doc/current/lib/module-gc.html for a brief
axplanation.).
Just
More information about the Python-list
mailing list