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!pipex!uunet!maunakea!kurt
From: kurt@Data-IO.COM (Kurt Guntheroth)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Message-ID: <D0JzqA.nB@maunakea.Data-IO.COM>
Sender: usenet@maunakea.Data-IO.COM (The News)
Nntp-Posting-Host: rabies
Organization: Data I/O Corporation
References: <D03Iwn.Jn5@research.att.com> <3boujh$o0c@news.parc.xerox.com> <JYL.94Dec8204808@frstprsn.eng.sun.com>
Date: Fri, 9 Dec 1994 17:10:57 GMT
Lines: 38
Xref: glinda.oz.cs.cmu.edu comp.lang.c:119966 comp.lang.c++:102385 comp.lang.lisp:15963

In article <JYL.94Dec8204808@frstprsn.eng.sun.com> jyl@toss.eng.sun.com writes:
>
>refcounting with
>suitable implementations of e.g. delete in C++ will allow the debugging of
>programs locally even in a setting where these programs operate together
>with other programs, potentially written by other programmers. I'm aware
>that GC systems exist which have been instrumented with memory tracing
>but these act non-locally, only catching the error long after it has
>happened.
>
>I agree that refcounting may be (depending on the implementation's degree
>of sophistication) less efficient at execution time. However consider the
>programmer's time which is saved by finding the errors locally. 

Twice in my career I have had the experience of implementing a system twice;
the first time using reference counting and the second time using garbage
collection.  It was my experience both times that reference counting was
devilishly difficult to get working right, and garbage collecting, with its
concentration of memory management activity into a few modules, was simpler
and more efficient. 

The first time this result came as a big surprise to me.  We had wanted
to do garbage collection but figured it would be too difficult and too
inefficient so we did reference counting.  But our data structures were
complex and did not have simple LIFO kinds of lifetime relationships so 
object destruction was not simple.  We had many bugs mostly resulting from
things being deallocated too soon, and performance was aweful.  We
implemented a simple mark-and-sweep collector in about 10 days, and were
amazed at the increase in performance and the disappearance of all our bugs.

The second time this happened to me, I deliberately converted to garbage
collection as a method to remove a number of known memory management bugs
and a memory leak.  I was pleased to discover that the same magic worked
again.  It was not challenging to implement the garbage collector, and after
a few weeks of testing, the collector was stable.

I like garbage collection.  I think it's easier to implement and more
efficient than reference counting.
