www.digitalmars.com         C & C++   DMDScript  

D - big arrays.

reply Mikael Haapakoski <mikael.haapakoski gmail.com> writes:
while i tried to make int array[1000][1000][1000] compiler gave error, 
with array litlle bigger than [510][510][2] compiler halts. why so? if i 
want to use arrays such big, do i have to use malloc?
May 10 2005
next sibling parent Thomas <thomas no.wherer> writes:
Mikael Haapakoski schrieb am Tue, 10 May 2005 17:41:11 +0300:
 while i tried to make int array[1000][1000][1000] compiler gave error, 
 with array litlle bigger than [510][510][2] compiler halts. why so? if i 
 want to use arrays such big, do i have to use malloc?

Note: Please post to the "digitalmars.D.learn" newsgroup instead of the depricated "D" group.
May 10 2005
prev sibling parent Derek Parnell <derek psych.ward> writes:
On Tue, 10 May 2005 17:41:11 +0300, Mikael Haapakoski wrote:

 while i tried to make int array[1000][1000][1000] compiler gave error, 
 with array litlle bigger than [510][510][2] compiler halts. why so? if i 
 want to use arrays such big, do i have to use malloc?

Maybe because static arrays are created on the stack, your application doesn't have enough stack space? Creating a dynamic array might work. int[][][] X; X.length = 1000; for(int i = 0; i < X.length; i++) { X[i].length = 1000; for(int j = 0; j < X[i].length; j++) X[i][j].length = 1000; } Or maybe you can create one dimensional array and do your own indexing... int[1000*1000*1000] X; Just out of curiosity, and this is not a criticism, but why does one need such large arrays in RAM? -- Derek Melbourne, Australia 11/05/2005 9:15:04 AM
May 10 2005