comp.lang.ada
 help / color / mirror / Atom feed
From: Christopher Broeg <broeg@astro.uni-jena.de>
Subject: Re: many exceptions cause memory leak?
Date: Tue, 25 Oct 2005 09:32:20 +0200
Date: 2005-10-25T09:32:20+02:00	[thread overview]
Message-ID: <djkn27$boi$1@lc03.rz.uni-jena.de> (raw)
In-Reply-To: <m27jc2bs78.fsf@grendel.local>

Simon Wright wrote:
> Christopher Broeg <broeg@astro.uni-jena.de> writes:
> 
>>I am by no means an expert in programming but I figured that all
>>memory assigned by pointers is returned. I do not use my own storage
>>pool but allocate just by
>>is new...
>>so it is all on the heap, I guess.
> 
> GNAT doesn't automatically free this memory until the end of the
> program. You need to free it yourself.

I do use unchecked deallocation on all pointers. I now have used gnatmem 
and found one memory leak that was my fault. There are still a few 
thousand "leaks" due to ada exception handling, though. Gnatmem output 
follows:

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

Allocation Root # 1
-------------------
  Number of non freed allocations    :12702
  Final Water Mark (non freed mem)   :  80.87 Kilobytes
  High Water Mark                    :  80.87 Kilobytes
  Backtrace                          :
    a-except.adb:1396 <ada__exceptions___elabb>

I do think that the program now stays constnat in size, or at least 
asymtotically approaches a relatively small constant size in memory. 
running the code over night, the high water mark of the entire program 
was small, so I hope the problem is solved. But since the program had 
already finished by this morning, I couldn't check independently using 
top, also I could not check whether this means reserved memory only and 
what happens with the virtual memory. It used to be twice as large as 
the reserved. I'll know in another 10 hours if everything is fine now.

Still, I am wondering if the above begaviour is normal. It is only 60kB, 
so no big deal, but 12702 non freed allocations? Is this normal? They 
always stem from line 1396 in a-except.adb. It is the place where a 
dummy procecdure called ZZZ is called. It appears to me that this should 
be a one-time per program lifetime event. Does this mean that there are 
12702 somehow independent exception occurences in my program?

thanks for all your help,

Chris



  reply	other threads:[~2005-10-25  7:32 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 [this message]
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
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