What is the maximum size of an object in 32 and 64 bits?

6

Specifically the array can have up to 4 billion elements, I think, and the most common element size sizes should be 4, 8, or 16 bytes.

I ask, what is the maximum size that the object can occupy in memory? Would it be 4 GB in 32 bits? Is it unlimited in 64 bits?

    
asked by anonymous 24.04.2017 / 16:45

2 answers

5

If by object you mean an array , System.Array uses Int32 as index - then its limit is defined by System.Int32.MaxValue (2.147.483.647, or 0x7FFFFFFF in hexadecimal .)

The pre-.Net 4.5 limit was 1.2GiB . It was possible to force the limit to 2.4GiB. The maximum addressing size is 24TiB , but only in 64-bit environments, with the following definition in the file .config :

<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
</configuration>

Sources: 1 , 2 .

    
24.04.2017 / 16:58
3

Depends heavily on the version of the .NET Framework that you will be using, versions prior to 4.5 had a 2 GB limit that could be a problem for caching on "large" systems;

With version 4.5 the "gcAllowVeryLargeObjects" functionality was introduced, which allows 64-bit systems to use larger amounts of RAM;

I think the program will be limited to the amount of RAM that the Windows version can use:

link

    
24.04.2017 / 16:58