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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!feeder.news-service.com!ecngs!feeder.ecngs.de!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 12:58:28 -0600 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Using local storage pools... Date: Wed, 23 Feb 2011 19:01:22 +0000 Reply-To: brian@shapes.demon.co.uk Message-ID: <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-DwOK+U4av+Ao7zxoP1Lq2FpRJCrpegthVT6S6j0M6U2ZKUS73xK8M0M1aKw/TXBlTJbRqRJXd2Dj95n!++9VcQU4xwvBwdJ72Jtp7iAOlgRJ4hH6ZJWzh6zGOTLJlIcP/oQ1xf7kamNutih5+loOo0gWPJN4!OYE= 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: 2898 Xref: g2news1.google.com comp.lang.ada:17560 Date: 2011-02-23T19:01:22+00:00 List-Id: I am trying to learn a little about storage pools, with a view to (hopefully) using local pools to improve the Binary_Trees benchmark in the same way as some of the faster C benchmarks. Arguably they cheat : they do not explicitly free each tree node (the "free" call has been deleted!) but free the entire pool at the end of the loop. But if that's valid, Ada should be able to do the same. http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Some-Useful-Memory-Pools.html suggests System.Pool_Local offers a way to do likewise - a pool that is automatically reclaimed when it goes out of scope. This turns out to have its own performance problem, but that is another story... 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? NOTE - using System.Pool_Global.Unbounded_No_Reclaim_Pool (commented out) instead of the pool shown, works as expected. (Tested on GCC4.5.0 and Libre 2010) - Brian ------------------------------------------------------------------------------------ with System.Pool_Local; with System.Pool_Global; with Ada.Unchecked_Deallocation; procedure pooltest is type Node; type Treenode is access Node; type Node is record Left : Treenode := null; Right : Treenode := null; Item : Integer := 0; end record; P : System.Pool_Local.Unbounded_Reclaim_Pool; --P : System.Pool_Global.Unbounded_No_Reclaim_Pool; for Treenode'Storage_Pool use P; procedure free is new Ada.Unchecked_Deallocation(Node, Treenode); TestNode : Treenode; begin Testnode := new Node'(null, null, 1); free(Testnode); end pooltest; ------------------------------------------------------------------------------------