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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: newbie: can't read fast enough... :-) memory leaks... Date: Wed, 03 Sep 2014 22:32:51 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <479b2efe-0238-4b2a-8b05-cb1a0b4a57e5@googlegroups.com> <1409739464.7121.235.camel@obry.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 4 Sep 2014 05:32:53 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="5b4eadb0ecf28f7f740a0e18f3715b8f"; logging-data="22362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GDXw/6Sp9Kk9+yVJkyedMbLNh6rj3Evw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Cancel-Lock: sha1:LRaw6zgUUTqOhNxCaOkZUh4LU2s= Xref: number.nntp.dca.giganews.com comp.lang.ada:188856 Date: 2014-09-03T22:32:51-07:00 List-Id: On 09/03/2014 09:57 PM, Brad Moore wrote: > > declare > type String_Access is access String; > A, B : String_Access; > begin > A := new String'("String 1"); > B := new String'("String 2"); > ... -- Operate on the data. > end; > -- A and B are automatically freed here because the String_Access > -- is finalized since the scope of the declaration of the access > -- type is being exited, and finalizing an access type also > -- finalizes its collection (allocated objects designated by that > -- type). > > This is a nice way to free up a bunch of objects that are no longer needed, if > it can be guaranteed that the objects are only needed in a nested scope. I like > this better than garbage collection, because the > deallocation occurs more consistently, when and where it is needed. > I view this as being less error prone, if one is able to take advantage of this > approach. Recent comments here in another thread indicate that this only works if 'Storage_Size is defined for the access type. -- Jeff Carter "Hello! Smelly English K...niggets." Monty Python & the Holy Grail 08