Funny – Newsgroup post about OutOfMemoryException

This just got posted to the ASP.NET newsgroup:

I'm getting an OutOfMemoryException when I initialize a byte array in
C# like

Byte[] test = new Byte[420000000];


Atleast he/she figured out what line was the likely culprit.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to Funny – Newsgroup post about OutOfMemoryException

  1. Greg says:

    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 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 …

  2. Simon says:

    What an idiot!

  3. I would assume that the computer he run it at had 512 MB or so.
    Even 1Gb will often refuse to do this.

  4. karl says:

    I can see some slow for loops…

  5. J says:

    That’s only 410 MB.