comp.lang.ada
 help / color / mirror / Atom feed
* can GNATmem report a memory leak when, in fact, no leak exists - a false positive?
@ 2012-03-09  1:03 Matt Borchers
  0 siblings, 0 replies; only message in thread
From: Matt Borchers @ 2012-03-09  1:03 UTC (permalink / raw)


I am using GNATmem to detect leaked memory which is working quite well.  However, I am finding that there are some allocations reported as memory leaks that I cannot verify as actual leaks.  I count the number of allocations of the Type (the number of 'new's that occur) and subtract the number of deallocations of the Type and I get zero.  Every allocation has a matching deallocation.

So my first question is, is it possible to write code in such a way that will 'trick' GNATmem into thinking there is a leak but not actually leak memory?  For example, perhaps:
 A) an allocation in thread (task) A that is deallocated in thread B, or
 B) an allocation whose access Type is stored in a collection Type (such as a tree) to be deallocated at a much later time when the tree is destroyed, or
 C) when there is a dereference of an access Type into a variable of the actual Type that does not require deallocation.  I.e. x := y.all; where 'y' is a variable of an access Type to T and 'x' is a variable of Type T.

One of the biggest leak offenders in my code (as reported by GNATmem) is GNAT's AWS product.  I am using an older release, v2.3.0, but I am told that testing v2.10.0 did not change the leak behavior but had other adverse performance consequences.  Are there known leaks in GNAT's AWS product?

The largest leak reported is from the 'binary_data' routine in the AWS.Status package (remember I'm using v2.3.0).  This routine returns a 'Stream_Element_Array' which is the result of dereferencing the 'Binary_Data' field of the 'Data' Type.  There is no allocation that happens by calling this routine which is why I'm confused why GNATmem would report a leak here.  Basically, this follows the example (C) that I wrote above where 'x' is a global variable of type 'Stream_Element_Array' with a large fixed size.

If there are known code constructs that can confuse GNATmem, I would be very interested to learn what they are.

Any thoughts would be very helpful to me.  Thank you.
Matt



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-09  1:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09  1:03 can GNATmem report a memory leak when, in fact, no leak exists - a false positive? Matt Borchers

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