Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Max Memory Use 2GB even for x64 Assemblies

I've read (http://blogs.msdn.com/joshwil/archive/2005/08/10/450202.aspx) that the maximum size of an object in .NET is 2 GB.

Am I correct in assuming that if I have an Object that takes up 256 MB Memory, since it is a reference type, I can have an array of these 256 MB Objects where all the objects together may takeup >2GB Memory as long as the size of the reference array stays below 2 GB?

like image 840
Nate Avatar asked Jun 11 '09 16:06

Nate


1 Answers

Yes, your assumption is correct.

The 2GB limit applies to each object individually. The total memory used for all objects can exceed 2GB.

(Whether the runtime is able to allocate enough memory for your requirements is another matter. I doubt if it could find a full 2GB of spare memory on a 32bit machine, but it shouldn't be a problem on 64bit.)

like image 125
LukeH Avatar answered Oct 21 '22 09:10

LukeH