[Python-Dev] Garbage collector problem

Kevin Jacobs jacobs@penguin.theopalgroup.com
Fri, 28 Jun 2002 16:07:33 -0400 (EDT)


On Fri, 28 Jun 2002, Jeremy Hylton wrote:
> Your suggestion seems to be that we should treat references from older
> generations to newer generations as external roots.  So a cycle that
> spans generations will not get collected until everything is in the
> same generation.  Indeed, that does not seem harmful.

Not really -- I'm saying that certain types of containers tend to hold
references to other, much larger, containers.  These small containers tend
to be ephemoral -- they appear and disappear quickly -- but sometimes are
unlucky enough to be around when a collection is triggered.  In my example,
the small containers were bound-method objects, which store back-references
to their class instance, a huge list, which will live in generation 2 very
quickly.

I do not advocate making objects store which generation they belong to, but
rather to delay the traversal of certain containers until after generation
0.  This means that they've been around the block a few times, and may have
fallen in with a bad cyclical crowd.

This annotation should be added to objects that tend to shadow other
containers, like bound-methods, iterators, generators, descriptors, etc.

In some tests using real workloads, I've found that upwards of 99% of these
ephemoral objects never make it to a generation 1 collection anyway.

Haulin' garbage,
-Kevin

--
Kevin Jacobs
The OPAL Group - Enterprise Systems Architect
Voice: (216) 986-0710 x 19         E-mail: jacobs@theopalgroup.com
Fax:   (216) 986-0714              WWW:    http://www.theopalgroup.com