From: Aurele <aurele.vitali@gmail.com>
Subject: Re: Allocators and memory reclamation
Date: Mon, 28 Jan 2008 14:00:11 -0800 (PST)
Date: 2008-01-28T14:00:11-08:00 [thread overview]
Message-ID: <ae678887-7f94-4fb2-8cb2-95517f859f75@p69g2000hsa.googlegroups.com> (raw)
In-Reply-To: 4a2fe64e-ae34-4093-88ec-1dc612a9adbd@v29g2000hsf.googlegroups.com
On Jan 28, 8:49 am, Maciej Sobczak <see.my.homep...@gmail.com> 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;
next prev parent reply other threads:[~2008-01-28 22:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox