Getting core.exception.OutOfMemoryError error on allocating large arrays

John Colvin john.loughran.colvin at gmail.com
Sun Mar 3 08:03:51 PST 2013


On Sunday, 3 March 2013 at 15:52:49 UTC, John Colvin wrote:
> On Sunday, 3 March 2013 at 14:05:02 UTC, Sparsh Mittal wrote:
>> I am running
>>
>>
>> enum long DIM = 1024L * 1024L * 1024L* 8L ;
>> void main() {
>>  auto signal = new double[DIM];
>> }
>>
>>
>> and getting core.exception.OutOfMemoryError error.  One option 
>> is to use short/int, but I need to use double. Also, on using 
>> large arrays, computer becomes slow.
>>
>> Is there no workaround at all, so that I can work on large 
>> arrays? Please let me know.
>
> Assuming double.sizeof==8 on your machine, You're requesting 
> 1024*1024*1024*8*8 bytes = 68GB, do you have that much RAM 
> available?

Depending on your OS, you will of course have to take in to 
account page file limits and swap partition sizes.    
Nonetheless, 68GB is a huge amount of memory to have in a single 
array, that's 8.6 billion numbers. In reality I doubt you will 
need that many.


More information about the Digitalmars-d-learn mailing list