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,fdc38a13551814d X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Allocators and memory reclamation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4a2fe64e-ae34-4093-88ec-1dc612a9adbd@v29g2000hsf.googlegroups.com> <5f1fb537-239c-4700-8280-560287ce5677@d21g2000prf.googlegroups.com> Date: Tue, 29 Jan 2008 10:38:56 +0100 Message-ID: <6knrol553hbe$.wk24c95m72xc$.dlg@40tude.net> NNTP-Posting-Date: 29 Jan 2008 10:38:56 CET NNTP-Posting-Host: d3a40972.newsspool2.arcor-online.net X-Trace: DXC=ERd1fS>WY76U`5g[@c]@J1A9EHlD;3Yc24Fo<]lROoR1nkgeX?EC@@0I=7W9L76J24[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>?MO]T^L8=7L9 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:19647 Date: 2008-01-29T10:38:56+01:00 List-Id: On Mon, 28 Jan 2008 14:27:23 -0800 (PST), Maciej Sobczak wrote: > I'm interested in the pattern of calls to Deallocate in the given > program. > My understanding, initially, was that Deallocate is called kind of > implicitly when the storage pool is torn down together with its > associated access type. > It does not seem to be the case, but the storage pool itself can keep > track of the allocated blocks and at the end do "something" with them. In my understanding Deallocate is just not called. One can enforce this behavior when there is GC by applying the pragma Controlled, but not the reverse. > The interesting part is that finalizers of My_Type were called and > this is even before the pool gets finalized itself (I've checked it by > overriding Finalize for My_Pool_Type). This is good, because after > that only raw memory remained to be reclaimed. > The question is - who called the finalizers of allocated objects? Any > AARM paragraphs for this would be welcome. There is a linked list of controlled objects allocated in the access type scope. I don't think this is "good". The language should be consistent in its choices, if the design choice was to leak memory, then it finalization must leak as well! (:-)) >>> Another question relates to the order of finalizing objects. If the >>> storage pool is torn down when the access type goes out of scope, is >>> the order of finalizing objects guaranteed? >> >> AFAIK, it is not. Why should it be? > > Why not? :-) > > If not, then there is additional (automatic) question: how can I make > it guaranteed? Again, what for? (:-)) A properly designed program should never rely on such stuff. I mean either there should be a GC with the properties defined, and BTW, no GC usually tells anything about not only in which order but also when and if something gets collected; or else it should do absolutely nothing. > There is a related problem which I've found while playing with the > above code example: I cannot have a pointer to the standard pool. > In other words, this: > > type Pool_Ptr is access Root_Storage_Pool'Class; > PP : Pool_Ptr := Integer'Storage_Pool'Access; > > is not possible, because the standard storage pool is not aliased. > How can I get a reference to the standard pool so that I don't have to > repeat the "Integer'Storage_Pool" million times? > > What about this: > > P : Root_Storage_Pool'Class := Integer_Ptr'Storage_Pool; type Integer_Ptr is access Integer; P : Root_Storage_Pool'Class renames Integer_Ptr'Storage_Pool; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de