Max number of array dimensions

  • Thread starter Thread starter Suresh Guddanti
  • Start date Start date
S

Suresh Guddanti

I wish to know the maximum number of array dimensions that
the .net framework can handle.

When I tried the following code:

Dim myLengthsArray() As Integer = {1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 1, 1, 1, 1, 1, 1, 1}
Dim arrValue As Array = Array.CreateInstance(GetType
(String), myLengthsArray)


I got the following error: 'System.OutOfMemoryException'
occurred in mscorlib.dll

Can anyone help in this.

Thanks
 
Not sure if my math adds up correctly, but I think you are trying to create
(if it was only a byte array) over 700Gb of array memory + overhead.
Figuring arrays are zero based, the calc would be something like
2*3*4*5*6*7*8*9*10*11*12*13*2*2*2*2*2*2*2 = 797,058,662,400 entries.

Anyone, anyone? Is my math really bad???
 
You're right. There is no limit on number of dimensions (well, theoretically
there's probably platform word size limit, on Win32 that would be
4,294,967,296 dimensions) but you're limited by the memory. And a 32-bit
system can access 4 GB without a special memory management (and .Net doesn't
have one). Allocating almost 200 times that will fail...

Jerry
 
Jerry III said:
You're right. There is no limit on number of dimensions (well, theoretically
there's probably platform word size limit, on Win32 that would be
4,294,967,296 dimensions) but you're limited by the memory. And a 32-bit
system can access 4 GB without a special memory management (and .Net doesn't
have one). Allocating almost 200 times that will fail...

Jerry

From that 4GB only 2GB is available to the user the other half is reserved by the system.
The CLR v1.1 however is LARGEADDRESSAWARE, that means that a program can have 3GB of user space available if:
- boot.ini flag 3GB iset,
- and you ran editbin on the PE file in order to set LARGEADDRESSAWARE:Yes).

Willy.
,
 
Back
Top