Newsgroups: alt.lang.design,comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.lang.ada
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!pipex!uunet!noc.near.net!inmet!asp!mg
From: mg@asp.camb.inmet.com (Mitch Gart)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Message-ID: <D06r8x.JBy@inmet.camb.inmet.com>
Sender: news@inmet.camb.inmet.com
Organization: Intermetrics, Inc.
X-Newsreader: TIN [version 1.1 PL8]
Date: Fri, 2 Dec 1994 13:38:57 GMT
Lines: 40
Xref: glinda.oz.cs.cmu.edu comp.lang.c:118892 comp.lang.c++:101322 comp.lang.lisp:15900 comp.lang.ada:24284

One thing to keep in mind here is that the number of pointers, 
compared with the total program code and data size, is usually
a lot smaller in Ada programs than in Lisp or C++.  In Lisp 
everything is a pointer.  In C++ it is common to use lots of 
pointers when constructing class hierarchies.  It is common for
an application program that uses code from pre-existing classes
to end up executing lots and lots of pointer operations, perhaps
without the application having explicitly declared any pointers
or explicitly called "new" or malloc().

In contrast, pointer operations are less dominant in Ada programs.
For non-Ada readers of this stream, think of Ada as being like
Pascal in this area.  A program gets a pointer if it explicitly 
calls "new", or if it declares pointer objects and dereferences them.  
But there aren't lots of hidden, implicit pointers everywhere.  
It is possible to write an Ada (or Pascal) program whose main 
calculations involve pointer operations, but this is not the typical 
case.  Perhaps as Ada 9X class hierarchies are built up, this will 
change.

Since pointers are less heavily used in Ada, and since an important
Ada application domain is embedded real time programs that must run 
for a long time without memory leaks and without stopping to do
garbage collection, reference counting may be more appropriate 
for Ada than for other languages.  Ada needs a way of 
automatically reclaiming unused storage, but from what I have read 
about generational and other GC schemes it appears that they very 
complicated, and are optimized for the big cases, where a program 
performs millions of pointer operations.  If the following points
are true about a reference counting scheme:

- protects against memory leaks
- predictable, guaranteed to not stop a program while doing GC
- costs a bit, in proportion to how heavily pointers are used,
  but the cost is predictable
- relatively simple to implement

then RC sounds like a reasonable memory reclamation scheme for Ada.

	Mitch Gart
