Newsgroups: alt.lang.design,comp.lang.c,comp.lang.c++,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!ix.netcom.com!netcom.com!hbaker
From: hbaker@netcom.com (Henry G. Baker)
Subject: Re: Reference Counting (was Searching Method for Incremental Garbage Collection)
Message-ID: <hbakerCzpJy7.ItH@netcom.com>
Organization: nil
References: <CzpJ7I.44D@world.std.com>
Date: Wed, 23 Nov 1994 06:42:07 GMT
Lines: 32
Xref: glinda.oz.cs.cmu.edu comp.lang.c:117571 comp.lang.c++:100024 comp.lang.lisp:15770

In article <CzpJ7I.44D@world.std.com> tob@world.std.com writes:
>OK, I've been following this thread for a bit, and there are two
>objections to reference counting that IMO aren't as strong as they
>appear. I await other opinions of course.
>
>0:      It orphans circular structures.
>
>Well, if you do it naively, sure. But the way I've always handled such
>memory is that there's a top structure (head pointer, usually) that owns
>everything inside. Everything outside just borrows memory. Anything that
>includes circular pointers is complex enough that it belongs in such an
>encapsulation. Obviously you would count references to the head, not to
>every member.
>
>1:      It's slow, due to count update overhead.
>
>Again, I get the impression that what one has in mind is a very naive
>implementation. Say, one that "thrashes" every time there's a loop that
>copies and destroys a pointer. I have even heard people who consider
>that finding the length of a list in Lisp inc/dec's for _every step_!
>The purpose of reference counting is to handle "sibling" deep pointers
>where you don't know which one will get destroyed first. Reference
>counting anything whose order of destruction you can predict at compile
>time seems pointless.

Good ideas.  Now can you formalize these rules & prove conditions
under which any & all garbage will be collected?  I'm trying to
understand _provably safe styles_ of programming.

Henry Baker
Read (192.100.81.1) ftp.netcom.com:/pub/hbaker/README for ftp-able papers.
WWW archive: ftp://ftp.netcom.com/pub/hbaker/home-page.html
