This just got posted to the ASP.NET newsgroup:
I'm getting an OutOfMemoryException when I initialize a byte array inC# like this:Byte[] test = new Byte[420000000];
Atleast he/she figured out what line was the likely culprit.
That's <i>only</i> 410 MB.
I can see some slow for loops...
I would assume that the computer he run it at had 512 MB or so.
Even 1Gb will often refuse to do this.
What an idiot!
just be glad it wasnt a stackalloc.
it is however quite common to initialize large byte arrays ... doing the above code once is not a big deal (allocating one time a 410mb chunk in the LOH is something I alot of (then I dish out arraysegment<byte> chunks of this larger array back to callers who need variable sized buffers .. if this were in an aspx page where it would be happenning often it is a very big deal ...