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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,13d6cd0af0d0d769 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-22 16:37:19 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!RRZ.Uni-Koeln.DE!uni-duisburg.de!zib-berlin.de!news.mathworks.com!uunet!world!blanket.mitre.org!linus.mitre.org!spectre!eachus From: eachus@spectre.mitre.org (Robert I. Eachus) Newsgroups: comp.lang.ada Subject: Re: Does memory leak? Date: 23 Mar 1995 00:37:19 GMT Organization: The Mitre Corp., Bedford, MA. Distribution: world Message-ID: References: <3kopao$ekg@nef.ens.fr> NNTP-Posting-Host: spectre.mitre.org In-reply-to: sands@clipper.ens.fr's message of 22 Mar 1995 09:06:31 GMT Date: 1995-03-23T00:37:19+00:00 List-Id: In article <3kopao$ekg@nef.ens.fr> sands@clipper.ens.fr (Duncan Sands) writes: > Does Ada leak memory? I would like to believe it doesn't, but > how does it manage not to (without having to use unchecked > deallocation)? Ada does not leak memory. Ada is a language standard, and both Ada 83 and Ada 95 do a good job of always permitting a compiler to do it right, and of noting where it may be difficult. Let me take this a little further (and add another candidate for the top 10 Ada 83 references list ;-) 13.10.1(5) says that "FREE(X), when X is not equal to null, is an indication that the object designated by X is no longer required, and that the storage it occupies is to be reclaimed." Why the "mealy mouthed" wording? Because it is possible that the object designated by X is, in fact, still required, and reclaiming the storage is likely to cause a system crash. No one wanted the RM to require the run-time to reclaim storage which might be locked by other processes, etc. AI-356 deals with these sorts of cases, and details the possible behaviors. Now, back to the original issue, there are compilers that leak storage. Some of them are Ada compilers. Much, much more common is for programmers to write programs that leak storage and blame the compilers. This is an especially prevelent practice in C. It is much less common in Ada--in fact in Ada, when it comes to memory leaks, compiler bugs are a close second to program logic bugs. There are a very few cases where programs are deliberately designed to leak storage because it is too expensive to avoid it, but these are very rare. (One case that I had something to do with involves a command line parameter package...it may be possible to determine when the storage required goes away, but in most cases you would be saving less in stack or heap space than you lose to added code space.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...