From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,48d98d9c0c6c8b81,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-16 17:48:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!jfk3-feed1.news.algx.net!dfw3-feed1.news.algx.net!allegiance!newsfeed.news2me.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3D34BF92.BAB26BA3@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: GNAT memory leak in compiled code (3.13p/Linux) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 17 Jul 2002 00:48:25 GMT NNTP-Posting-Host: 63.191.73.221 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1026866905 63.191.73.221 (Tue, 16 Jul 2002 17:48:25 PDT) NNTP-Posting-Date: Tue, 16 Jul 2002 17:48:25 PDT Xref: archiver1.google.com comp.lang.ada:27171 Date: 2002-07-17T00:48:25+00:00 List-Id: 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;