This one throws an OutOfMemoryException
.
Target framework .NET 3.5, running on a 64-bit Windows 2008 R2 Standard.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
byte[] test = new byte[Int32.MaxValue];
}
}
}
According to documentation, array length must simply be a positive 32-bit integer but apparently that is not the only restriction to look out for.
Why does memory run out in this case?
That is 2 gigabytes of ram. Max value of 32 bit int is 2147483647, converted to megabytes is 2048, or 2 gigabytes. The machine may actually have run out of memory. See: Maximum Memory a .NET process can allocate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With