64-bit platform. NET Framework array limits cannot exceed 2GB size. This limitation is a very big problem for workers who need to use large matrices and vector computing.
No matter how much RAM you have, once you work with large matrices and vectors, you often throw a System.OutOfMemoryException exception, as shown in:
Reference Program
class program { privatestaticvoid Main (string[] args) { int150000000; var large=newdecimal[arrysize]; Console.ReadLine (); } }
Fortunately, it is. NET Framework 4.5 introduces a configuration property in run-time mode that makes the total array size larger than 2 GB for 64-bit applications.
You only need to enable the Gcallowverylargeobjects element to control the behavior of the. NET garbage-collection System (garbage collection systems).
Reference templates
<?XML version= "1.0" encoding= "Utf-8"?><Configuration> <Startup> <supportedruntimeversion= "v4.0"SKU=". netframework,version=v4.5 " /> </Startup> <Runtime> <gcallowverylargeobjectsenabled= "true" /> </Runtime></Configuration>
You can see the result without throwing an exception, can run normally, as follows
This way, you can make better use of the available memory when using a huge array on a 64-bit platform.
You can combine this setup with the Garbage-collection system (garbage collection) to improve. However, the maximum number of elements for the. NET Framework 4.5 and. NET Framework 4.0 arrays remains the same.