Re: Memory management clarification



"Frank J. Lhota" <NOSPAM.lhota@xxxxxxxxxxx> writes:

> Maciej Sobczak wrote:
> > Hi,
> > Trying to learn a bit of Ada I came across a statement that memory
> > allocated from the pool will be implicitly reclaimed when the acces
> > variable used to reference it goes out of scope.
>
> No, that is not true. What is true is that if an access type goes out of
> scope, then the data allocated from the pool for that type will be
> reclaimed. See ARM 13.11 (18).

That's not quite true, either. Most implementations use a global heap
by default, and never automatically reclaim memory. If you use a
Storage_Size clause on a local access type, then what you say is true.
But local access types are not very useful.

> Most Ada implementations do not support garbage collection, and with
> such implementations, your examples would simply create a lot of garbage.

Right.

- Bob
.



Relevant Pages

  • Re: Basic Explaination of OO in Ada
    ... An access type is equivalent to a pointer in C, ... in Ada may or may not be an actual address, it could be an offset into ... a block of memory. ...
    (comp.lang.ada)
  • Re: Inter-object pointer problem
    ... with an access type, but the Ptr_B doesnt exist until I have called ... If this were C I would instantiate A_Structure as a static ... This is so far from being correct Ada that it's impossible to tell what you're trying to do, but I'd suggest you pull the instantiation of B_Pkg out of the procedure. ... If you can provide a better example, with information such as the specifications of the packages and the definition of B_Pointer_Type, we can probably help you better. ...
    (comp.lang.ada)
  • Re: Large arrays (again), problem case for GNAT
    ... > the GNAT code accessing large data structures. ... enough memory on my machine to run it (at least, ... general access type if you are going to end-run Ada's heap management.) ... really is to use a supported compiler; you do really get what you pay for. ...
    (comp.lang.ada)
  • Re: Not null feature with anonymous and named access types
    ... and named access type. ... case due to memory leak as the result of memory deallocation ... using plain pointers, arena allocators, garbage collectors, etc to manage ...
    (comp.lang.ada)
  • Re: Allocators and memory reclamation
    ... procedure Foo is ... storage is taken from the storage pool associated with the Int_Ptr ... the access type itself goes out of scope and it is also when the ... As a result no memory is leaked in the above code ...
    (comp.lang.ada)