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,419864ed91cc937d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!goblin1!goblin3!goblin.stu.neva.ru!news.imp.ch!newsfeed-0.progon.net!progon.net!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: heap size exceeded for large matrices 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: <14007b1b-c290-4c73-a0ec-d3c5195b83d4@t20g2000yqa.googlegroups.com> <4c7a360b$0$10227$ba4acef3@reader.news.orange.fr> <340c87af-1f15-4590-baa9-ec7e864b7048@l20g2000yqm.googlegroups.com> <4c7ada3c$0$2372$4d3efbfe@news.sover.net> Date: Mon, 30 Aug 2010 11:55:02 +0200 Message-ID: <1xwfrisok7o8o.171bx0cou8174$.dlg@40tude.net> NNTP-Posting-Date: 30 Aug 2010 11:55:01 CEST NNTP-Posting-Host: eba56977.newsspool4.arcor-online.net X-Trace: DXC=n2CnSV[Ec\L0YVY]kmLTlD4IUK On Mon, 30 Aug 2010 07:44:00 +0000 (UTC), Natasha Kerensikova wrote: > On 2010-08-29, Peter C. Chapin wrote: >> Be aware that you may now have to explicitly deallocate the array at >> some point. How necessary that is will depend on your program and some >> other factors. It's something to keep in mind. > > Are there some facilities like C++'s auto_ptr (i.e. containers that > behaves like pointers but with a reference counter, so that when the > last container is finalized the pointed data is release automatially)? > I haven't seen any, have I missed it? Are you looking for a reference-counted GC or for a pointer that brings the referenced object down with it, when goes out of scope? > I guess it's so easy to write that if it's not standardized, it's > probably not because of complexity. Is there something in Ada language > or in Ada philosophy that would make them almost useless (except in rare > situations like OP's)? If you meant the latter, you don't need anything to write as the language already provides collection through scoped access types (pointers). Consider this: with Ada.Finalization; with Ada.Text_IO; use Ada.Text_IO; package P is type Object is new Ada.Finalization.Limited_Controlled with null record; overriding procedure Finalize (X : in out Object); end P; package body P is procedure Finalize (X : in out Object) is begin Put_Line ("I am down"); end Finalize; end P; The object Object prints "I am down" when destroyed. Now if you either declare an access type in a scope or else use an anonymous type then any object allocated by new and assigned to this pointer will be automatically destroyed when the scope is left: declare type Pointer is access all Object; X1 : Pointer := new Object; X2 : access Object := new Object; begin ... -- Using X1 and X2 end; -- Targets of X1 and X2 are finalized and freed here For a reference-counted GC there are several implementations of. For example this: http://www.dmitry-kazakov.de/ada/components.htm#Objects_etc -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de