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 X-Google-Thread: 103376,ed3a51e96a1c868b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!216.196.110.146.MISMATCH!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 23 Feb 2011 17:57:06 -0600 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Using local storage pools... Date: Thu, 24 Feb 2011 00:00:00 +0000 Reply-To: brian@shapes.demon.co.uk Message-ID: References: <7elam6trrv39c3p9iop4fiduqa1jrat4r4@4ax.com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-gQgTSUJFpYSheJJLwlsvyh4ppqCPwAKRVT4oYVz9gFeu25sGYyqKDvrxw7C6qOkd4eWxVNOzduLE0GA!5VemRcik0fTkBqDGJ0nM8pkq3BJWdyZNZHJ6N5tOfJ0mKXuLVqm2NlosSXT+TQ6axndWvXDFpvxO!4Uw= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3481 Xref: g2news1.google.com comp.lang.ada:17572 Date: 2011-02-24T00:00:00+00:00 List-Id: On Wed, 23 Feb 2011 21:01:51 +0000, Simon Wright wrote: >Brian Drummond writes: > >> The question(or four) for now is ... should the following really raise >> Storage_Error, i.e. am I doing something silly, and if so, what? Or >> is this a bug in Gnat? > >Looks to me like a bug in GNAT. I expect it's not been found before >because the point of this pool type is that you *don't* deallocate, but >leave it up to finalization! Probably, but the doc doesn't say that freeing is illegal, and the source file (s_pooloc.ads/b) does have a deallocate routine, so I believe it OUGHT to work... I can imagine cases where you free to improve memory footprint, but for whatever reason you can't (or don't) entirely eliminate memory leaks (so cleanup at a well-defined point)- in that case, the pool should allow both strategies. When I created a "local pool" per task, it only left scope on termination, therefore the memory footprint blew up without freeing. You could argue this was my programming error. >I'm not quite clear how we can use this pool in the binary-trees >benchmark, since the rules say you create a class to represent the tree, >which must include the access types, and the storage pool needs to exist >before the access types are used. Perhaps a generic? Exactly. In my binary_trees experiments I have made the Treenode package a generic. That part seems to work... >Even then, why not just declare an access type in the appropriate scope >and let the compiler figure out how to deallocate storage on scope exit? >(in other words, I don't see why GNAT includes System.Pool_Local in the >first place). I think it's so you can also declare a storage pool along with the locally-declared access type, (i.e. locally instantiated generic) such that the entire pool goes out of scope and can be deleted on leaving the scope. Using the main pool, you would have to deallocate the locally declared access types but leave the longer-lived objects... Unfortunately, the current implementation of System.Pool_Local derives from System.Pool_Global, so it is implemented on the main heap, and its "Finalize" simply loops over every object freeing them individually. Therefore there is no performance gain this way... - Brian