From: Theodore P. <The...@so...> - 2006-09-12 11:15:56
|
On Mon, 2006-09-11 at 11:15 -0700, Patrik Jonsson wrote: > Anirban Banerjee wrote: > > Hello everyone, > > Newbie here :) . I'm trying to create a 4D array > > with 151X151X151X151 float elements. When I run the code, I get an > > error, and using gdb I see the following messages. > > > > I'm using Array <float, 4> ford(151,151,151,151); to declare the > > array. I'm not doing anything fancy after this. But the execution > > stops when it hits this declaration. I think its possibly a memory > > allocation error. If anyone has come across something similar, cold > > you please let me have a pointer as to how to get around this problem. > > Any help would be greatly appreciated. > Hi Anirban, > > get more memory or reduce the array size. This array will have 500 > million elements at 4 bytes each which adds up to roughly 2GB of memory. > So unless you have >>2GB memory on your system, you will get a bad_alloc. And even then depending on the system you use, you may not get the memory you request. At least in standard 32bits i386 linux distribution, the maximum memory per process for data is 2Gb. To overcome this, you also need to get an x86-64 distrib or recompile the kernel (I'm not sure on this one). Theo. |