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: "Robert I. Eachus" Subject: Re: garbage collection Date: 1999/08/18 Message-ID: <37BB3C67.64DC8383@mitre.org>#1/1 X-Deja-AN: 514407131 Content-Transfer-Encoding: 7bit References: <7pe93j$ehg$1@dailyplanet.wam.umd.edu> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.mitre.org X-Trace: top.mitre.org 935017345 9042 129.83.41.77 (18 Aug 1999 23:02:25 GMT) Organization: The MITRE Corporation Mime-Version: 1.0 NNTP-Posting-Date: 18 Aug 1999 23:02:25 GMT Newsgroups: comp.lang.ada Date: 1999-08-18T23:02:25+00:00 List-Id: Ronald Ayoub wrote: > I need this to be clarified for me. If an implementation doesn't provide > garbage collection then that storage is forever lost, is that correct? Or > does this mean that it may not be garbage collected but when a call to new > is executed it is at that time scene as available. Please clarify. This seems > like a real bad idea not to have some form of garbage collection inforced. The correct answer is c) All Ada compilers provide some forms of storage management, and most Ada programs lose no storage. But very few Ada implementations support compacting garbage collectors. 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. 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. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...