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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5653f0bd43045b85 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: garbage collection Date: 1999/08/20 Message-ID: #1/1 X-Deja-AN: 515025292 References: <7pe93j$ehg$1@dailyplanet.wam.umd.edu> <37BB3C67.64DC8383@mitre.org> X-Complaints-To: usenet@nusku.cts.com X-Trace: nusku.cts.com 935135370 14015 198.68.168.21 (20 Aug 1999 07:49:30 GMT) Organization: CTS Network Services NNTP-Posting-Date: 20 Aug 1999 07:49:30 GMT Newsgroups: comp.lang.ada Date: 1999-08-20T07:49:30+00:00 List-Id: "Robert I. Eachus" writes: [...] > I could go into all the gory details, but that about sums it up. The > validation tests do include several tests to insure that storage is not > lost in many common situations, but there is no requirement that storage > be freed the moment their are no more references. Many Ada compilers > instead free the storage when the access type goes out of scope for some > or all types. > > Why? Three reasons. Freeing the storage when the type goes out of > scope allows for predictable storage reclamation which is very useful in > real-time code. Second, the user can easily manage storage for any type > the way he wants to. Insisting on "full" garbage collection would limit > the user's choices. [...] BTW, in my experience most access types don't go out of scope until the program terminates, because they're declared in library-level packages. The automated reclamation can only take place if the access type is declared directly or indirectly within a subprogram or a task body (there may be other cases). (I'm not sure how typical my experience is; how common is it to declare an access type within a subprogram?) Note that declaring an access *object* within a subprogram doesn't let the storage it refers to be reclaimed; the access value could have been copied to an object in an outer scope before the subprogram completed. > And finally, Ada allows return values from functions which are > unbounded, and for which the storage is "automagically" managed. If you > define a function which returns a string in Ada, there is no need for > explicit alloc and free calls or the equivalent. So in ninety percent > or more of the cases where you need garbage collection in other > languages, you don't even need explicit allocations in Ada. Right, I think this is the biggest reason that the lack of garbage collection in most Ada implementations isn't (much of) a problem. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> One of the great tragedies of ancient history is that Helen of Troy lived before the invention of the champagne bottle.