Oct 082013

Why use gcAllowVeryLargeObjects ?

Please note that this post is only applicable for .net 4.5 and above.

Having trouble with .net array size limit, i.e. 2GB on a 64 bit target. Use gcAllowVeryLargeObjects tag in application config file to work around this issue. A sample config file will look as follows…

    <gcallowverylargeobjects enabled="true" />

Please read the docs very carefully, there are some caveats that you should be aware off… (from MSDN)

Using this element in your application configuration file enables arrays that are larger than 2 GB in size, but does not change other limits on object size or array size:

  • The maximum number of elements in an array is UInt32.MaxValue.
  • The maximum index in any single dimension is 2,147,483,591 (0x7FFFFFC7) for byte arrays and arrays of single-byte structures, and 2,146,435,071 (0X7FEFFFFF) for other types.
  • The maximum size for strings and other non-array objects is unchanged.

Read More