Does anyone understand gcAllowVeryLargeObjects?

fomrat

New member
Joined
Nov 24, 2019
Messages
1
Programming Experience
10+
The docs say: "Arrays greater than 2 GB in total size are enabled on 64-bit platforms" and ".NET Framework 4.5 and later versions" and "The maximum index in any single dimension is 2,147,483,591 (0x7FFFFFC7) for byte arrays".

I can create a two-dimensional [2, x] array that's 4GB in total:

Byte[,] bigArray0 = new byte[0x2, 0x7FFFFFC7];

and (once filled), it dutifully occupies 4 GB in memory. (I do get an exception if I even try to examine bigArray0.Length ("'bigArray0.Length' threw an exception of type 'System.OverflowException'), but it works.)

But I can't do a [3, x]:

Byte[,] bigArray0 = new byte[0x3, 0x7FFFFFC7];

without "Array dimensions exceeded supported range" upon declaring the array. It doesn't seem to make sense. I'm not running up against the Int32.MaxValue limit on indices, nor a 2 GB limit on size, so what's the problem?

I can even do [2, x] three times:

Byte[,] bigArray0 = new byte[each, elements];
Byte[,] bigArray1 = new byte[each, elements];
Byte[,] bigArray2 = new byte[each, elements];


and consume 12,707,624 KB.

I can't find anything other than references that simply parrot the docs. Any ideas?
 
The part that you are missing is this:
but does not change other limits on object size or array size:
UInt32.MaxValue is 2GB.
0x7FFFFFC7 is almost 1GB elements.
2 rows of that will give you almost 2GB elements.
3 rows of that will definitely surpass 2GB elements.
 
Back
Top Bottom