Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 10, 2005 big arrays. | ||||
---|---|---|---|---|
| ||||
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 Re: big arrays. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mikael Haapakoski |
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 Re: big arrays. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mikael Haapakoski | 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 |
Copyright © 1999-2021 by the D Language Foundation