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-Thread: 103376,f8b8f80c415d1eed X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!postnews.google.com!1g2000prf.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: Memory leak in BLAS/LINPACK - GNAT on OS X Date: Fri, 18 Apr 2008 14:43:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: <35f81199-9ab3-4098-9798-fbc96bb24c0a@1g2000prf.googlegroups.com> References: <7fa5fc26-6843-4000-bea7-f8a956b20b3f@2g2000hsn.googlegroups.com> NNTP-Posting-Host: 75.171.61.127 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208555015 32154 127.0.0.1 (18 Apr 2008 21:43:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 18 Apr 2008 21:43:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 1g2000prf.googlegroups.com; posting-host=75.171.61.127; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.14) Gecko/20080409 Camino/1.6 (like Firefox/2.0.0.14),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20993 Date: 2008-04-18T14:43:35-07:00 List-Id: On Apr 16, 4:06 pm, tkrauss wrote: > There have been a few messages on the GNAT-OSX mailing list about an > apparent memory leak in the Ada.Numerics.Long_Real_Arrays > implementation. The setup is an OS X box (10.4) with the GNAT 4.3 > compiler from the macada.org site. The Ada.Numerics.Long_Real_Arrays > is using the Apple-supplied BLAS and LINPACK libraries under the > hood. The code snippet below (plagiarized from Jerry's post on the > mailing list) leaks memory (as reported by top). Note that the same > code but with Long_Complex types does not appear to have this problem. > > Has anyone seen this problem on other platforms? Do other languages > on OS X behave this way? I'm not sure how to track down the guilty > party here. Is it Apple's BLAS or LINPACK libraries or something in > the GNAT Long_Real_Arrays multiply method? > > with Ada.Numerics.Long_Real_Arrays; > use Ada.Numerics.Long_Real_Arrays; > > procedure tst_simple is > v : Real_Vector(1 .. 100_000) := (others => 1.23); > res : Real_Vector(1 .. 100_000); > begin > for i in 1..1000 loop > res := 123.456 * v; > end loop; > end tst_simple; I'm really interested to see what comments people have about this problem. The sample program given by the original poster hits 1 GB of RAM use in only a few seconds. (I kill it then.) As he says, the complex-number version of the same program does not leak. Also, the following program which implements a local version of scalar-vector multiplication does not leak. It looks like either the * operator is hosed in GNAT or there is something wrong with Apple's BLAS. Clearly programs that do this operation are not practical at this time. Here's the program with a local override of "*" for scalar-vector multiplication that behaves well. with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; procedure tst_mult_2 is v : Real_Vector(1 .. 100_000) := (others => 1.23); res : Real_Vector(1 .. 100_000); function "*" (a : Long_Float; x : Real_Vector) return Real_Vector is Result : Real_Vector (x'range); begin for index in x'range loop Result(index) := a * x(index); end loop; return Result; end "*"; begin for i in 1..100 loop res := 123.456 * v; end loop; end tst_mult_2; Jerry