.NET Max Memory Use 2GB even for x64 Assemblies

后端 未结 2 587
孤城傲影
孤城傲影 2020-12-17 18:47

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

相关标签:
2条回答
  • 2020-12-17 19:18

    "In .NET 4 and earlier, no object could be larger than 2GB in size, even in 64-bit processes. For certain workloads that use large arrays, however, this size limit can be constraining. As such, .NET 4.5 supports lifting the limit for arrays in 64-bit processes, such that arrays may be larger than 2GB. This means, for example, that you could allocate an array of Int32.MaxValue Int32s, even though such an array will consume 8GB. Large objects in .NET are allocated on a special heap, known not coincidentally as the Large Object Heap (LOH); .NET 4.5 has also seen significant performance improvements to the LOH, including usage of better algorithms for managing free memory in the heap."

    http://msdn.microsoft.com/en-us/library/hh285054(v=VS.110).aspx

    http://blogs.msdn.com/b/somasegar/archive/2012/05/16/net-improvements-for-cloud-and-server-applications.aspx

    0 讨论(0)
  • 2020-12-17 19:40

    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.)

    0 讨论(0)
提交回复
热议问题