NET Framework 4.5 new features (iii) 64-bit platform supports arrays larger than 2 GB in size

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.