To GC or not to GC?

Martin v. Loewis martin at v.loewis.de
Thu Nov 21 16:00:14 EST 2002


Kenny Tilton <ktilton at nyc.rr.com> writes:

> 1. Is that doc up to date? I see Mar 2002, not too shabby.

Yes.

> 2. Well, I should almost wait before asking further, but if you'll
> forgive a little lookahead, that "supplements reference counting"
> scares me. Is ref counting history or not? mind you, i understand
> there is a lot of code out there taht must be supported, but for new
> code...?

What do you mean, "for new code"? The reference counting is still
done, for all code. There is no reasonable way to disable it for some
code but leave it active for other code.

There is also nothing wrong with reference counting. If the reference
counter drops to zero, the object is gone before the cyclic garbage
collector is even invoked.

Furthermore, the cyclic GC *relies* upon refcounting. It does not,
itself, collect any memory. Instead, it picks an arbitrary object from
the cycle and asks to clear itself, i.e. to drop all references it may
have to other objects. That breaks the cycle in a single place, and
causes refcounting to unwind all objects in the cycle.

Regards,
Martin




More information about the Python-list mailing list