C # Array size analysis (with Debug and release differences remembered during the test)

Source: Internet
Author: User

How much is the theoretical maximum length of a C # array? Once asked over Niang, Google, seemingly did not come to a more accurate answer, nothing is what Int32 the maximum value ah what, today finally decided to write a software to test their own, in a few different computers inside the actual test to see how big?

Just do it. The maximum length of several common types, such as bool array, int array, string array, long array, and float array, is found by using binary search algorithm, and the results are as follows on three computers respectively:

Computer \ Array Type bool Int String Long Float
Computer 1-PC 2147483591 536870897 268435447 268435448 536870897
Computer 2-x3650 Server 2147483591 536870897 268435447 268435448 536870897
Computer 3-x250 Notebook 2147483591 536870897 268435448 268435448

536870897

Basic configuration of Computer 1-pc:

Computer 2-x3650 Server:

Computer 3-x250 Notebook:

From the above table, it can be very clear that these several system environment of various types of array of the maximum length, a bit strange is, a string type array, three system environment a little different, looking at the expert pointing.

PS: In the process of writing the test software, found and realized a debug and release program differences, degrees Niang and Google on most of the statement are, release more lightweight, do a lot of optimization, the program runs more efficient, but really embodied in the program is, the definition of an array, For example int[] list = new Int[1000],debug is immediately allocated memory space, and release, if not used is not allocated memory space, which led me to the test program at the very beginning of the situation, the debug mode is running well, And the release mode is not normal, because I am by catching an exception to determine the maximum length of the type array in the system

C # Array size analysis (with Debug and release differences remembered during the test)

Related Article

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.