comp.lang.ada
 help / color / mirror / Atom feed
* GNAT memory leak in compiled code (3.13p/Linux)
@ 2002-07-17  0:48 Marc A. Criley
  2002-07-17  5:28 ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Marc A. Criley @ 2002-07-17  0:48 UTC (permalink / raw)


The appended program, when compiled with GNAT 3.13p on Linux (RedHat
6.2) experiences a memory leak.  The offending line contains an implicit
dereference that occurs when assigning to the Buf array slice.

Does this leak occur in later versions of GNAT?  Or on other platforms?

The way I observed the memory leak occurring was by running the
executable in one window and using the following Linux command in
another:

top -bq | grep mem_leak

The fifth column is the total process size, which can be observed to
continuously grow as the program runs.

(Note to Robert Dewar:  If this memory leak is present in later versions
of GNAT, a bug report will of course be submitted to ACT via the
appropriate mechanism.)

Marc A. Criley, Consultant
Quadrus Corporation
www.quadruscorp.com

-------------------------------------------------------------------------

with Ada.Strings.Unbounded;
use  Ada.Strings.Unbounded;

procedure Mem_Leak is

   type Us_Uc_Array is array (Natural range <>) of Unbounded_String;

   type Us_Uc_Array_Ptr is access Us_Uc_Array;

   Buf : Us_Uc_Array_Ptr;

   Count : Natural := 0;

   procedure F(S : Us_Uc_Array) is
   begin
      -- The following line results in a memory leak when this program
      -- is compiled with GNAT 3.13p on Linux.
      Buf(1..S'Length) := S;

      -- Comment out the above line, and uncomment the following to
      -- see the program run with no memory leak.
      -- Buf.all(1..S'Length) := S;
   end F;

begin
   Buf := new Us_Uc_Array(1..10_000);
   for I in 1..50 loop
      F((1..110 => To_Unbounded_String("Hello")));
      delay 0.5;
   end loop;
end Mem_Leak;



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT memory leak in compiled code (3.13p/Linux)
  2002-07-17  0:48 GNAT memory leak in compiled code (3.13p/Linux) Marc A. Criley
@ 2002-07-17  5:28 ` Simon Wright
  2002-08-13 11:36   ` Preben Randhol
  2002-07-17  8:37 ` Fabien Garcia
  2002-07-20  2:51 ` Dave Taylor
  2 siblings, 1 reply; 5+ messages in thread
From: Simon Wright @ 2002-07-17  5:28 UTC (permalink / raw)


"Marc A. Criley" <mcq95@earthlink.net> writes:

> The appended program, when compiled with GNAT 3.13p on Linux (RedHat
> 6.2) experiences a memory leak.  The offending line contains an
> implicit dereference that occurs when assigning to the Buf array
> slice.

3.14p, 3.15a and gcc-3.1 all show stable memory usage. Slackware 7.1.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT memory leak in compiled code (3.13p/Linux)
  2002-07-17  0:48 GNAT memory leak in compiled code (3.13p/Linux) Marc A. Criley
  2002-07-17  5:28 ` Simon Wright
@ 2002-07-17  8:37 ` Fabien Garcia
  2002-07-20  2:51 ` Dave Taylor
  2 siblings, 0 replies; 5+ messages in thread
From: Fabien Garcia @ 2002-07-17  8:37 UTC (permalink / raw)


I have no memory leak with Gnat 3.13p/Windows XP (sorry for the later :)

Fabien




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT memory leak in compiled code (3.13p/Linux)
  2002-07-17  0:48 GNAT memory leak in compiled code (3.13p/Linux) Marc A. Criley
  2002-07-17  5:28 ` Simon Wright
  2002-07-17  8:37 ` Fabien Garcia
@ 2002-07-20  2:51 ` Dave Taylor
  2 siblings, 0 replies; 5+ messages in thread
From: Dave Taylor @ 2002-07-20  2:51 UTC (permalink / raw)


It works OK in 3.13p / MacOS X.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT memory leak in compiled code (3.13p/Linux)
  2002-07-17  5:28 ` Simon Wright
@ 2002-08-13 11:36   ` Preben Randhol
  0 siblings, 0 replies; 5+ messages in thread
From: Preben Randhol @ 2002-08-13 11:36 UTC (permalink / raw)


On 17 Jul 2002 06:28:29 +0100, Simon Wright wrote:
> "Marc A. Criley" <mcq95@earthlink.net> writes:
> 
>> The appended program, when compiled with GNAT 3.13p on Linux (RedHat
>> 6.2) experiences a memory leak.  The offending line contains an
>> implicit dereference that occurs when assigning to the Buf array
>> slice.
> 
> 3.14p, 3.15a and gcc-3.1 all show stable memory usage. Slackware 7.1.

Also 3.14p on Debian 3.0

Preben



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-08-13 11:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-17  0:48 GNAT memory leak in compiled code (3.13p/Linux) Marc A. Criley
2002-07-17  5:28 ` Simon Wright
2002-08-13 11:36   ` Preben Randhol
2002-07-17  8:37 ` Fabien Garcia
2002-07-20  2:51 ` Dave Taylor

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