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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: newbie: can't read fast enough... :-) memory leaks... Date: Thu, 4 Sep 2014 09:23:29 +0200 Organization: cbb software GmbH Message-ID: References: <479b2efe-0238-4b2a-8b05-cb1a0b4a57e5@googlegroups.com> <1409739464.7121.235.camel@obry.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: yj8+JIQUMOEawvIM7K49kA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:188860 Date: 2014-09-04T09:23:29+02:00 List-Id: On Wed, 03 Sep 2014 22:32:51 -0700, Jeffrey Carter wrote: > 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. An arena pool would do the job. The Storage_Pool attribute would statically ensure that the access type won't outlive the pool. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de