From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: heap size exceeded for large matrices
Date: Mon, 30 Aug 2010 11:55:02 +0200
Date: 2010-08-30T11:55:01+02:00 [thread overview]
Message-ID: <1xwfrisok7o8o.171bx0cou8174$.dlg@40tude.net> (raw)
In-Reply-To: slrni7moa0.dki.lithiumcat@sigil.instinctive.eu
On Mon, 30 Aug 2010 07:44:00 +0000 (UTC), Natasha Kerensikova wrote:
> On 2010-08-29, Peter C. Chapin <chapinp@acm.org> 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
next prev parent reply other threads:[~2010-08-30 9:55 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-29 8:50 heap size exceeded for large matrices John Raymond Dore
2010-08-29 9:51 ` Yannick Duchêne (Hibou57)
2010-08-29 10:42 ` Simon Wright
2010-08-29 15:33 ` John Raymond Dore
2010-08-29 10:27 ` Pascal Obry
2010-08-29 15:14 ` Brian Drummond
2010-08-29 16:16 ` John Raymond Dore
2010-08-29 22:06 ` Peter C. Chapin
2010-08-29 22:47 ` Brian Drummond
2010-08-30 9:45 ` Brian Drummond
2010-08-30 11:04 ` Cyrille
2010-08-30 13:01 ` System.Pool_Local.Unbounded_Reclaim_Pool (Was: heap size exceeded for large matrices) Jacob Sparre Andersen
2010-08-30 13:38 ` Dmitry A. Kazakov
2010-08-30 14:08 ` Robert A Duff
2010-08-30 14:14 ` J-P. Rosen
2010-08-30 7:44 ` heap size exceeded for large matrices Natasha Kerensikova
2010-08-30 9:41 ` Brian Drummond
2010-08-30 9:55 ` Natasha Kerensikova
2010-08-30 9:55 ` Dmitry A. Kazakov [this message]
2010-08-30 10:21 ` Georg Bauhaus
2010-08-30 18:56 ` Jeffrey Carter
2010-08-30 16:55 ` Simon Wright
2010-08-30 17:00 ` Robert A Duff
2010-08-30 19:51 ` Simon Wright
2010-08-30 16:58 ` Simon Wright
2010-08-31 17:56 ` Natasha Kerensikova
2010-08-29 17:57 ` Pascal Obry
2010-08-29 15:35 ` John Raymond Dore
2010-08-29 17:57 ` Pascal Obry
2010-08-29 19:19 ` Ludovic Brenta
2010-08-29 20:33 ` Pascal Obry
2010-08-29 21:17 ` Robert A Duff
2010-08-29 21:29 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox