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!howland.reston.ans.net!agate!darkstar.UCSC.EDU!news.hal.COM!decwrl!netcomsv!netcom.com!hbaker
From: hbaker@netcom.com (Henry G. Baker)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Message-ID: <hbakerD0oM3E.7s3@netcom.com>
Organization: nil
References: <hbakerD08qGF.4qM@netcom.com> <D0KDGE.31F@inmet.camb.inmet.com> <gmckee.1137578003A@news-2.csn.net>
Date: Mon, 12 Dec 1994 05:04:25 GMT
Lines: 37
Xref: glinda.oz.cs.cmu.edu comp.lang.c:120194 comp.lang.c++:102630 comp.lang.lisp:15992 comp.lang.ada:24621

In article <gmckee.1137578003A@news-2.csn.net> gmckee@cloudnine.com (Gary McKee) writes:
>In Article <D0KDGE.31F@inmet.camb.inmet.com>, bobduff@dsd.camb.inmet.com
>(Bob Duff) wrote:
>>In article <hbakerD08qGF.4qM@netcom.com>,
>>Henry G. Baker <hbaker@netcom.com> wrote:
>>>I just wanted to point out again that objects whose reference counts
>>>are always one, and the programmer/compiler knows this, avoid the
>>>usual overheads of reference counting.
>>
>>But it seems to me that in a language like Ada, if a given object only
>>has one reference pointing to it, and that fact is known at compile
>>time, then you would almost always declare that object as a normal
>>stack-allocated object.  So it would not be in the heap in the first
>>place, so reference counting would never occur.
>================================================================
>One counter-example would be the situation with compilers that limit the
>size of the stack space but not the size of the heap. 
>
>I have placed large, static arrays with predefined values onto the heap in
>order to leave the stack space for subprogram usage (especially recursive
>subprograms).

Another common example is a function that returns an object of
arbitrary size.  You don't know how much space to allocate for it
on the stack, and if you simply redefine the stack frame to include
the object (which was stack-allocated by the called function), then
you may waste huge amounts of space on the stack.  So you're better
off allocating it in a heap, but remembering that you have only
one pointer to it.

Henry Baker
Read (192.100.81.1) ftp.netcom.com:/pub/hb/hbaker/README for ftp-able papers.
WWW archive: ftp://ftp.netcom.com/pub/hb/hbaker/home.html
************* Note change of address ^^^        ^^^^
(It _is_ accessible, but Netcom is loaded; keep trying.)


