garbage collection / cyclic references
castironpi at gmail.com
Sat Mar 21 01:42:02 CET 2009
I was reading and Googling about garbage collection, reference
counting, and the problem of cyclic references.
Python's garbage collection module claims to be able to detect and
break cyclic garbage. Some other languages merely prohibit it. Is
this the place to ask about its technique?
I understand that the disadvantage is a non-deterministic order of
deletion/finalization. It's an acceptable cost for the system I am
considering. I may even impose an arbitrary but consistent order on
it, such as by class name, by id, etc. (tm!).
After all the hullabaloo, I don't see that Python's purportedly
successful strategy amounts to anything more than a breadth-first
search, plus some optimizations. Did I miss something? What are its
caveats and fragilities? If free software can do it, why isn't it all
over the industry? What disqualifies it from solved-problem status?
Finally, what are the costs and benefits of an additional
'__gc_clear__' special method, for example, that is the equivalent of
the 'tp_clear' method on extension types? Or, perhaps, a
'__gc_cycle__' method, that is called with the attribute names of
attributes that lead to a cycle, that would be called prior to the
More information about the Python-list