.NET object size limit

.NET limits any object to max 2 GB even on 64 bit platforms. You can create your own data type, that uses multiple objects to store more data, thus getting around the 2 GB limit of a single object. For instance a List<float[]> would allow you to store more than 2 GB, but you would have to write the necessary plumbing code to make it behave similar to a single, large array.

You may also want to check this question.


In versions of .NET prior to 4.5, the maximum object size is 2GB. From 4.5 onwards you can allocate larger objects if gcAllowVeryLargeObjects is enabled. Note that the limit for string is not affected, but "arrays" should cover "lists" too, since lists are backed by arrays.


I don't think there is an easy workaround for this, it seems to me there could be difficulties implementing a heap without a 2Gb limit on object size.

Maybe you would be better breaking the data up some how. It should be possible to write a class that behave like an array but splits the data up into fixed sized chunks under the hood.

Tags:

.Net