Re: Allocators and memory reclamation
- From: Aurele <aurele.vitali@xxxxxxxxx>
- Date: Mon, 28 Jan 2008 14:00:11 -0800 (PST)
On Jan 28, 8:49 am, Maciej Sobczak <see.my.homep...@xxxxxxxxx> wrote:
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;
To avoid memory leak, rewrite as...
with Ada.Unchecked_Deallocation;
type Int_Ptr is access Integer;
procedure Free is new Ada.Unchecked_Deallocation( Integer,
Int_Ptr );
procedure Foo is
P : Int_Ptr;
:
begin
P := new Integer;
:
Free( P );
:
end Foo;
procedure Main is
begin
loop
Foo;
end loop;
end Main;
.
- References:
- Allocators and memory reclamation
- From: Maciej Sobczak
- Allocators and memory reclamation
- Prev by Date: Re: Allocators and memory reclamation
- Next by Date: Re: Allocators and memory reclamation
- Previous by thread: Re: Allocators and memory reclamation
- Next by thread: Re: Allocators and memory reclamation
- Index(es):