comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Extra footnote: Re: Size of Vector limited to 1024 MB of Heap Size
Date: Tue, 24 Jun 2008 23:36:11 GMT
Date: 2008-06-24T23:36:11+00:00	[thread overview]
Message-ID: <Lxf8k.138729$SV4.41061@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: iVe8k.138597$SV4.76767@bgtnsc04-news.ops.worldnet.att.net

0 - 1023MB 16-bit works -- 2GB

but in Ada: Integers are 4 bytes

0 - 1023MB 32-bit words -- 4GB 

So:

1024MB  16-bit elements would be (2GB+1 (16-bit words))

but

1024MB 32-bit elements aka 1024MB Integer would be 
   (4GB+1 (32-bit words))  -- STORAGE_ERROR

so it seam that you did get the full 4GB RAM memory.


But the statement

   Generic_Vector.Append (Evil_Vector, Integer'Last);

will create a vector size of 4GB with each element being 4 bytes 
giving a total size of 16GB.

So, use:

   Generic_Vector.Append ( Evil_Vector, ( Natural'Last / 4 ) ) ;

or better yet

   Generic_Vector.Append ( Evil_Vector, ( Natural'Last / Natural'Size ) ) ;


to give you a 1GB Vector size with an 4 byte element size that uses 
a total size of 4GB.


In <iVe8k.138597$SV4.76767@bgtnsc04-news.ops.worldnet.att.net>, anon@anon.org (anon) writes:
>Adjust your heap size in the linking phase. 
>
>In <g3qc68$5a5$1@aioe.org>, Dennis Hoppe <dennis.hoppe@hoppinet.de> writes:
>>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
>>   package Generic_Vector is new Ada.Containers.Vectors
>>     (Element_Type => Integer, Index_Type => Natural);
>>		
>>   Evil_Vector : Generic_Vector.Vector;
>>begin -- Heap
>>   loop
>>     Generic_Vector.Append (Evil_Vector, Integer'Last);
>>   end loop;
>>end Heap;
>>
>>
>>heap(6374) malloc: *** mmap(size=2147487744) failed (error code=12)
>>*** 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.
>>
>>
>>Best regards,
>>   Dennis Hoppe
>




  reply	other threads:[~2008-06-24 23:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24  8:44 Size of Vector limited to 1024 MB of Heap Size Dennis Hoppe
2008-06-24 15:03 ` Adam Beneschan
2008-06-24 17:32 ` Robert A Duff
2008-06-24 18:55 ` Peter Schildmann
2008-06-25 15:13   ` Dennis Hoppe
2008-06-25 17:26     ` (see below)
2008-06-25 21:09       ` Dennis Hoppe
2008-06-24 20:03 ` Gene
2008-06-24 20:38   ` Robert A Duff
2008-06-24 22:53 ` anon
2008-06-24 23:36   ` anon [this message]
2008-06-25  0:11     ` Extra footnote: " tmoran
2008-06-25  2:49       ` anon
2008-06-25  8:04         ` christoph.grein
2008-06-25 10:39 ` Peter Schildmann
2008-06-25 15:29   ` Dennis Hoppe
replies disabled

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