Newsgroups: comp.lang.dylan,comp.lang.lisp,comp.lang.java
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!news.sprintlink.net!in2.uu.net!nntp.cadence.com!news
From: Simon Kinahan <simonk>
Subject: Re: Garbage collection cost (was Re: Parenthesized syntax challenge)
Content-Type: text/plain; charset=us-ascii
Message-ID: <DGJp3I.7L2@Cadence.COM>
Sender: news@Cadence.COM
Content-Transfer-Encoding: 7bit
Organization: Cadence NVision
References: <44aa9a$j5h@miso.cs.uq.edu.au> <MARCOXA.95Oct4094304@lox.icsi.berkeley.edu> <453po8$175@Yost.com> <LUDEMANN.95Oct6140930@expernet26.expernet.com> <DGApp8.J41@undergrad.math.uwaterloo.ca> <MAD.95Oct13123618@tanzanite.math.keio.ac.jp> <45q3cg$jqg@voyager.internex.net>
Mime-Version: 1.0
Date: Mon, 16 Oct 1995 14:18:54 GMT
X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3 sun4c)
X-Url: news:45q3cg$jqg@voyager.internex.net
Lines: 47
Xref: glinda.oz.cs.cmu.edu comp.lang.dylan:5421 comp.lang.lisp:19529 comp.lang.java:1718

muzok@msn.com (muzo) wrote:

>just  a sec. Are you saying that the number of free call necessary in a GC
>system is different than the number of free calls in a malloc/free program
>which allocates the same number of objects ? If yes, I'd like to see a
>reference or discussion on this.

I can't give you a reference, but I promise you it is true. Firstly you need
to understand that in a garbage collected langauge you do not normally
make free calls. All temporary variables go out of scope eventually
and the GC algorithm 'notices' this when it is run and cleans up after
them. All other storage can be 'released', that is the programmer 
explicitly says the storage can be freed, but does not free it himself.
In functional languages, where storage is all temporary release is not
requiresd.

As I understand it the proof that GC is less expensive than malloc/free
is based on the copying style of garbage collector, used in may
newer compilers. The simplest form of copying GC keeps two blocks
of memory, both large enough to hold all active objects, and simply
copies all active objects from their current locatrions to locations in the
other block every so oftwen, marking the old block as free. This both
compacts the memory abnd 'implicitly' collects the garbage.

Now for the important point : the garbage collector only has to copy
every live object every so often, the equivalent program using free
cannot achieve the same efficiency because it has to free every 
single piece of ememory it uses explicitly. I can't rtemember
how to get from here to a proof, but I have seen it doen. 

>If you are not saying that (which I don't think you can), than a "perfectly
>implemented" malloc/free program has a lower bound in terms of memory
>management cost because the "programmer" (remember that person who wrote the
>perfect program ?) knows exactly when the memory is not needed anymore and
>doesn't incur any costs for finding out which objects are to be collected. IOW,
>a GC program's memory management cost will be always higher than that of a
>malloc/free program. 

Thats the point. The copying algorithm (to my knowledge this doesn't apply to
any other form og GC) never needs to find out which objects are allocated or
not. It just blindly copoies.

Simon

-- 
     1

