From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,b99897135d6631cc X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: David Starner Subject: Re: memory management and productivity User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) Message-Id: Newsgroups: comp.lang.ada References: <40d15023$1_1@baen1673807.greenlnk.net> <40d69121$1_1@baen1673807.greenlnk.net> <40d932fe_1@baen1673807.greenlnk.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 23 Jun 2004 22:06:57 GMT NNTP-Posting-Host: 12.72.88.217 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1088028417 12.72.88.217 (Wed, 23 Jun 2004 22:06:57 GMT) NNTP-Posting-Date: Wed, 23 Jun 2004 22:06:57 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:1835 Date: 2004-06-23T22:06:57+00:00 List-Id: On Wed, 23 Jun 2004 17:36:23 +0000, Bj�rn Persson wrote: > Could someone enlighten me a little on the mysteries of garbage? > > Since a garbage collector can apparently be compiled in as a library, > why isn't that good enough? Is it a great advantage to have it provided > by the compiler instead? The only library garbage collectors I know about are conservative; they assume that every pointer-size chunk of accessible memory is a pointer, (unless it's in a block of data that was allocated with a special function that tells the GC there are no pointers in that data.) They don't move memory because you can't adjust pointers if you can't tell pointers from integers. A garbage collector that was part of the compiler could tell integers from pointers (that is, be a precise collector instead of a conservative collector) and could move items in memory (which many high-performance GCs do.) This makes easier, for example, for a compiler to scan only the new stuff, which has a shorter live time than the stuff the program has kept around for a while. The first may be more important; a misplaced integer could potentially hold several megabytes of garbage in memory.