www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D - big arrays.

↑ ↓ ← 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
→ 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
→ 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