Simon Cozens wrote:
> Ref counting isn't garbage collection.
> http://www.jwz.org/doc/gc.html

Please explain that to Richard Jones and Rafael Lins who have
written a beautiful book surveying garbage collectors. Reference
counting is only given about 50 pages or so, but it's the *first*
50 pages...

Reference counting has three *really* nice features:

 1. ephemeral -- collector cost is spread across the entire
    runtime of the program; no collector pauses

 2. immediate -- garbage is collected as soon as possible
    which means expensive shared resources (like file handles)
    can be collected instead of explicitly managed

 3. cache friendly -- well at least it's not as unfriendly
    as a simple copying collector which tends to access pages
    in least-frequently-used order and destroys the OS's
    carefully tuned VM system

Reference counting also has application in distributed and parallel
environments because it doesn't require any global searches.

One very attractive collector for Perl would be to stay with
a reference count collector and only invoke a mark-sweep or copying
collector when the heap hits a high water mark. This would also
allow perl to use a small reference count, say 4 bits, since if
the max was hit the traversing collector would find the garbage
anyway.

BTW, jwz must have missed Tom's mini-howto on the use of "real"
as an insult. Or maybe he didn't. ;)

- Ken

Reply via email to