title: Why can't I create an object greater than 2GB in size in .NET, even on x64?
body: <p>After reading <a href="https://stackoverflow.com/questions/3106945/are-c-strings-and-other-net-apis-limited-to-2gb-in-size">Are C# Strings (and other .NET API’s) limited to 2GB in size?</a> I played around with large strings and arrays in .NET 3.5. I found that the largest array I could allocate was <code>int.MaxValue - 56</code> bytes. Similar thing for strings: the largest I could get was <code>(int.MaxValue - 58) / 2</code> characters (since each character took 2 bytes). After that it throws <code>OutOfMemoryException</code>.</p>
  
  <p><strong>Why does this limitation exist?</strong> Not that I've ever run into it in practice - I'm just curious about the inner workings of .NET.</p>
  
  <p>Yes, this was on a 64-bit machine with plenty of RAM, of course - and yes, the process was running as a 64-bit process. (I could actually allocate 3 such arrays or strings for a total memory usage of 6GB.)</p>