comp.lang.ada
 help / color / mirror / Atom feed
* Allocators and memory reclamation
@ 2008-01-28 13:49 Maciej Sobczak
  2008-01-28 14:52 ` gpriv
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Maciej Sobczak @ 2008-01-28 13:49 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Allocators and memory reclamation
@ 2008-01-29 11:06 Grein, Christoph (Fa. ESG)
  2008-01-29 12:50 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 15+ messages in thread
From: Grein, Christoph (Fa. ESG) @ 2008-01-29 11:06 UTC (permalink / raw)
  To: comp.lang.ada

Dmitry wrote:
> 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. 

No, just the reverse, pragma Controlled prevents automatic garbage
collection, see RM 13.11.3(1).


Eurocopter Deutschland GmbH
Sitz der Gesellschaft/Registered Office: Donauwoerth
Registergericht/Registration Court: Amtsgericht Augsburg HRB 16508
Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board: Dr. Lutz Bertling
Geschaeftsfuehrung/Board of Management:
Dr. Wolfgang Schoder, Vorsitzender/CEO; Friedrich-Wilhelm Hormel; Ralf Barnscheidt

CONFIDENTIALITY NOTICE 

This communication and the information it contains is intended for the addressee(s) named above and for no other persons or organizations. It is confidential and may be legally privileged and protected by law. The unauthorized use, copying or disclosure of this communication or any part of it is prohibited and may be unlawful. 
If you have received this communication in error, kindly notify us by return e-mail and discard and/or delete the communication. Thank you very much. 
It is possible for e-mails to be intercepted or affected by viruses. Whilst we maintain virus checks on our e-mails, we accept no liability for viruses or other material which might be introduced with this message. 




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-01-29 12:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-28 13:49 Allocators and memory reclamation Maciej Sobczak
2008-01-28 14:52 ` gpriv
2008-01-28 14:53 ` Lucretia
2008-01-28 16:00   ` gpriv
2008-01-28 22:46     ` Alex R. Mosteo
2008-01-28 15:15 ` Dmitry A. Kazakov
2008-01-28 22:27   ` Maciej Sobczak
2008-01-28 23:54     ` Adam Beneschan
2008-01-29  9:38     ` Dmitry A. Kazakov
2008-01-28 23:07   ` Randy Brukardt
2008-01-28 22:00 ` Aurele
2008-01-29  0:41 ` Robert A Duff
2008-01-29 11:12   ` Maciej Sobczak
  -- strict thread matches above, loose matches on Subject: below --
2008-01-29 11:06 Grein, Christoph (Fa. ESG)
2008-01-29 12:50 ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox