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

Asked

Viewed 665 times

6

Specifically the array can have up to 4 billion elements, I think, and the most common sizes of elements 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? It is unlimited in 64 bits?

2 answers

5


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

The.Net 4.5 pre-limit was 1.2 GB. It was possible to force the limit to 2.4GiB. Nowadays the maximum address 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.

  • If it is only the size of the array has this "limitation" of items that it has, well observed.

  • 1

    @Harlangomesnascimento Exact, and still has the fact that even the constructor allowing the initialization of a array with a long, the final object does not yet support an index of type long.

  • 1

    With the option gcAllowVeryLargeObjects the index can use System.UInt32.MaxValue, so it can go beyond the 2 billion elements.

  • That I didn’t know. Thanks for the @bigown tip!

3

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

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

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

https://msdn.microsoft.com/pt-br/library/windows/desktop/aa366778(v=vs.85). aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.