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.4 required=5.0 tests=BAYES_00,FAKE_REPLY_C, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,be4b51b40516c4c6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-25 05:47:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.litech.org!fr.ndsoftwarenet.com!teaser.fr!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Allocating Memory with "new" Date: Fri, 25 Apr 2003 07:46:43 -0500 Organization: ENST, France Message-ID: Reply-To: "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1051274857 30596 137.194.161.2 (25 Apr 2003 12:47:37 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 25 Apr 2003 12:47:37 +0000 (UTC) To: "comp.lang.ada mail to news gateway" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:36532 Date: 2003-04-25T07:46:43-05:00 ----- Original Message ----- From: "Peter Richtmyer" Newsgroups: comp.lang.ada To: Sent: Friday, April 25, 2003 5:33 AM Subject: Re: Allocating Memory with "new" > "Vincent Smeets" wrote in message news:<3ea8d041$0$4083$4d4ebb8e@read.news.de.uu.net>... > > > Every time an access type comes out of scope, the memory allocated by that > > access type can be freed (garbage collection). > > Thanks - that certainly explains it. I thought the programmer had > complete control of the memory allocated and that it would not be > freed until an Unchecked Deallocate (or the program ended). > >>From the addresses allocated, it looks like the allocation was done on the stack, instead of the heap. The compiler is free to do this, given that Mem_Block_Ptr is declared on the stack. Thus, this is not "garbage collection," but simply the fact that the allocated memory goes out of scope when the procedure returns. In this sense, the Rational compiler is "smarter" than GNAT, since allocation on the heap is more expensive than allocation on the stack. Incidentally, setting Mem_Block_Ptr to null is unnecessary, since the rules of Ada require access objects to be initialized to null. David