comp.lang.ada
 help / color / mirror / Atom feed
From: Christopher Broeg <broeg@astro.uni-jena.de>
Subject: Re: many exceptions cause memory leak?
Date: Wed, 26 Oct 2005 12:56:57 +0200
Date: 2005-10-26T12:56:57+02:00	[thread overview]
Message-ID: <djnndp$7kg$1@lc03.rz.uni-jena.de> (raw)
In-Reply-To: <369da$435e7da8$3ea6010b$8607@news.versatel.net>

Wiljan Derks wrote:
> "Christopher Broeg" <broeg@astro.uni-jena.de> wrote in message 
> news:djknki$cl6$1@lc03.rz.uni-jena.de...
>>>Global information
>>>------------------
>>>   Total number of allocations        :109993
>>>   Total number of deallocations      :97243
>>>   Final Water Mark (non freed mem)   :  29.85 Megabytes
>>>   High Water Mark                    :  29.90 Megabytes
> Still looks like you are loosing memory.
> Maybe a good tip:
> When and exception occurs one can easily asume that an inout variable of a 
> procedure
> alsready has the value assigned to its end location. Thus something like 
> this:
> procedure zzz(x: in out access y) is
> begin
>     x:=new ...
>    exception here
> end;
> When an exception occurs, one could assume that the new pointer is already 
> assigned
> to the structure that was passed to zzz.
> That is however not the case when using gnat.
> Typically, the inout parameter is a local variable for the procedure that is 
> stored on its final location when doing
> a normal procedure exit.
> This is a typical reason for loosing memory when doing exception processing.
> Changing the mode from inout to and access parameter fixes that.
> 
> 
Hi,

the ZZZ procedure is a procedure in the GNAT exception library. There 
are no pointers there, actually.

I think I might have found the reason for the memory loss, though:

I am using unchecked_acces to the data for the external HDF5 calls. The 
memory leak seems to be originating there.

If I have aliased variables do I have to manually free the memory?

i.e. I have:

declare
  Data      : H5_double.Data_1d(0..2) ;
begin
...
Status := H5_Double.H5aread (Attr_Id     => Attribute,
                              Mem_Type_Id => H5t_Native_double,
                              Buf         => Data(0)'Unchecked_Access);



data_1d is an array of aliased float. I don't do any manual deallocaton.

cheers,

Chris













  reply	other threads:[~2005-10-26 10:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21 10:07 many exceptions cause memory leak? Christopher Broeg
2005-10-21 15:38 ` Frank J. Lhota
2005-10-21 17:59   ` Robert Klungle
2005-10-21 18:13     ` Ed Falis
2005-10-24 11:29 ` Christopher Broeg
2005-10-24 20:00   ` Simon Wright
2005-10-25  7:32     ` Christopher Broeg
2005-10-25  7:42       ` Christopher Broeg
2005-10-25 12:34         ` Alex R. Mosteo
2005-10-25 12:55           ` Alex R. Mosteo
2005-10-25 18:50         ` Wiljan Derks
2005-10-26 10:56           ` Christopher Broeg [this message]
2005-10-25 13:09       ` Frank J. Lhota
2005-10-25 14:09         ` Christopher Broeg
2005-10-24 21:27   ` Andreas Schulz
2005-10-26 12:45 ` Christopher Broeg
replies disabled

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