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!allegra!alice!ark
From: ark@research.att.com (Andrew Koenig)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Message-ID: <D0E5tu.B3M@research.att.com>
Organization: Software Engineering Research Department
References: <D08x4q.KM8@research.att.com> <3c0qd3$b7m@network.ucsd.edu>
Date: Tue, 6 Dec 1994 13:37:05 GMT
Lines: 52
Xref: glinda.oz.cs.cmu.edu comp.lang.c:119444 comp.lang.c++:101881 comp.lang.lisp:15935

In article <3c0qd3$b7m@network.ucsd.edu> mbk@inls1.ucsd.edu (Matt Kennel) writes:

> I agree with your point, but given that 'm2" is only used in this way,
> what would be wrong with using maps 
> 
> 	Map<R, S> m1;
>   and   Map<R, T> m3;
> 
> and then letting pointer-based GC take care of things.  

Because I intend m1 to be many-to-one.  Replacing m2 with m3 therefore
means that instead of changing a single element of m2 I must change
many elements of m3.  Moreover, figuring out which elements to change
is precisely the GC problem I wish to avoid.

> Practical GC's don't free memory when it is "true" that the memory
> cannot be used, they only free memory when they themselves can prove
> that the memory isn't ever going to be used.  The lack of a live pointer
> guarantees this, but the presence of a live pointer doesn't guarantee that
> the memory will remain in use of course.

Exactly.

> In the general case it seems to me that definitively "knowing" if memory can
> be freed is as hard as actually simulating the computation, so it's
> essentially impossible.

... unless you know more about the algorithm than the garbage collector.

> However, I do not believe in the attitude "If you can't do it perfectly
> don't do even try" (that results in perfect solutions to trivial problems).

Nor do I.

> My personal feeling is that a GC is a powerful and useful engineering tool that
> is 
>   * practical and 
>   * should work very nicely in a substantial fraction of application 
>     software, and
>   * greatly alleviates a problem that is apprarently of great empirical
>     importance to humans.

I agree completely.  I also believe that GC

    * is not appropriate everywhere -- there are some applications where
      it does not make sense, and
    * does not solve every resource allocation problem, and
    * is not the only successful way of solving resource allocation
      problems -- sometimes other solutions work too.
-- 
				--Andrew Koenig
				  ark@research.att.com
