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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f479f3331eef5353 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!d45g2000hsc.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Re: Size of Vector limited to 1024 MB of Heap Size Date: Tue, 24 Jun 2008 13:03:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2ad55f4f-a463-4542-aa76-b1b6d20d9168@d45g2000hsc.googlegroups.com> References: NNTP-Posting-Host: 134.240.241.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1214337815 18672 127.0.0.1 (24 Jun 2008 20:03:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 24 Jun 2008 20:03:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d45g2000hsc.googlegroups.com; posting-host=134.240.241.2; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:848 Date: 2008-06-24T13:03:35-07:00 List-Id: On Jun 24, 4:44=A0am, Dennis Hoppe wrote: > Hi, > > my machine has 4 GB of RAM and I am wondering, why I can't use > at least 2 or 3 GBytes to run an Ada program. It seems, that my > Ada Compiler (Gnat 4.4.0) limit the memory to 2 GB per default. > Is it possible to allocate more than 2 GB? > > Here is a simple example of an "evil" vector, that gains > more memory in each pass. The program terminates exactly at > 1024 MB of used Heap memory. > > with Ada.Containers.Vectors; > > procedure Heap is > =A0 =A0package Generic_Vector is new Ada.Containers.Vectors > =A0 =A0 =A0(Element_Type =3D> Integer, Index_Type =3D> Natural); > > =A0 =A0Evil_Vector : Generic_Vector.Vector; > begin -- Heap > =A0 =A0loop > =A0 =A0 =A0Generic_Vector.Append (Evil_Vector, Integer'Last); > =A0 =A0end loop; > end Heap; > > heap(6374) malloc: *** mmap(size=3D2147487744) failed (error code=3D12) > *** error: can't allocate region > *** set a breakpoint in malloc_error_break to debug > > raised STORAGE_ERROR : heap exhausted > > I could not find a suitable Compiler switch or a parameter, that > can be set for the operating system (linux). "ulimit -v" is already > set to unlimited. > > "gnatmem" reports, that my water mark with 1024 MB is reached, but > the final water mark is, needless to say, higher. > Your code thrashes the heap pretty hard. Containers doubles the size of the vector's internal array each time it runs out. So the 2Gb request means 1Gb is already in use. Dont' know about your malloc(), but it's easy to see that a 1Gb allocated block in a 4Gb arena can preclude a further 2Gb allocation. What happens if call Reserve_Capacity(a, Natural'Last) at the beginning?