Re: many exceptions cause memory leak?



Frank J. Lhota wrote:
Do you ever call the following function from the Ada.Exceptions package?

   function Save_Occurrence
     (Source : Exception_Occurrence)
      return   Exception_Occurrence_Access;

This function allocates an Exception Occurrence from the heap and copies the data from Source into this new occurrence. It is up to the programmer to deallocate the result of this function. An instance of Unchecked_Conversion can be used for this purpose.

Failure to deallocate the results of the Save_Occurrence function would certainly result in a memory leak.

Also, is there any other Ada.Exceptions subprogram that you call? More info on how you are using exceptions might help us diagnose the problem.


Hi,

no I do not use save_occurence. I do use Raise_Exception and exception_information / message, though.

I am still running the code and it seems that the major memory leak problem is solved:

Global information
------------------
   Total number of allocations        :4216666
   Total number of deallocations      :3823682
   Final Water Mark (non freed mem)   :  32.21 Megabytes
   High Water Mark                    :  32.26 Megabytes

However, it appears strange to me that gnatmem detects so many non freed allocations originating in the exception package:

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

Of course, the program is still running, but in the past those occurences have not been freed upon termination. The memory use of 2.44 MB fits well with the fact that the code started out with a high water mark of roughly 29 MB and during the day raised the value to 32.21 MB. To be clear, this poses no problem at all to me, now. I am just curious and would like to understand what is going on.

I thank you all for the helpful comments and suggestions.

Chris
.



Relevant Pages

  • hunting down a memory leak
    ... the two most likely causes are either a memory leak in the ... ..NET exception classes. ... using (SqlConnection oConn = new SqlConnection(sConnection)) ... SqlCommand oCommand = oXMLCommand.CreateSqlCommand; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is this good style of C++?
    ... Ioannis Vranos wrote: ... >> If I implements RAII strictly, do you mean that memory leak can be ... >> normal running or exception thrown, objects in the scope will be ... >> not be released by releasing the pointer. ...
    (comp.lang.cpp)
  • Re: Western Digital MyBook versus Airport Extreme
    ... Chris Ridd wrote: ... to be okay, with the exception perhaps having a memory leak. ...
    (uk.comp.sys.mac)
  • Re: D2005 Code Folding
    ... then you'd have a memory leak. ... Putting a critical function before try means that we /trust/ this function to properly handle any exception after making any memory allocation that means we /expect/ it to behave like this: ... The difference here is that we are not interested in catching *any* exceptions that a call to ECS might throw, but instead, after ECS was *successfully* called and therefore critical section acquired, we need to ensure that the corresponding LCS gets called so we have to protect the code between these two calls that could raise an exception. ...
    (borland.public.delphi.non-technical)