Allocators and memory reclamation
- From: Maciej Sobczak <see.my.homepage@xxxxxxxxx>
- Date: Mon, 28 Jan 2008 05:49:35 -0800 (PST)
Hi,
Consider the following:
procedure Foo is
type Int_Ptr is access Integer;
P : Int_Ptr;
begin
P := new Integer;
P := new Integer;
P := new Integer;
end Foo;
procedure Main is
begin
loop
Foo;
end loop;
end Main;
In Foo above, three objects of type Integer are allocated and the
storage is taken from the storage pool associated with the Int_Ptr
access type.
What I understood before is that this storage pool is torn down when
the access type itself goes out of scope and it is also when the
memory is reclaimed. As a result no memory is leaked in the above code
- I can call Foo as many times as I want without any risk of running
out of memory. This is at least what I can observe with controlled
types.
The problem is that my understanding conflicts with what I've just
found in AARM (13.11):
"By default, the implementation might choose to have a single global
storage pool, which is used (by default) by all access types, which
might mean that storage is reclaimed automatically only upon partition
completion."
This means that the implementation might turn the above well-behaving
procedure into a memory leak. Is this correct?
Can I influence this behaviour to portably ensure that memory is
reclaimed when the access type goes out of scope?
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?
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
.
- Follow-Ups:
- Re: Allocators and memory reclamation
- From: Robert A Duff
- Re: Allocators and memory reclamation
- From: Aurele
- Re: Allocators and memory reclamation
- From: Jeffrey R. Carter
- Re: Allocators and memory reclamation
- From: Dmitry A. Kazakov
- Re: Allocators and memory reclamation
- From: Lucretia
- Re: Allocators and memory reclamation
- From: gpriv
- Re: Allocators and memory reclamation
- Prev by Date: Re: ANN: GNAT/GPL Solaris 10: 2007-solaris-x86
- Next by Date: Re: Allocators and memory reclamation
- Previous by thread: ANN: GNAT/GPL Solaris 10: 2007-solaris-x86
- Next by thread: Re: Allocators and memory reclamation
- Index(es):
Relevant Pages
|