I have got a 2 GB machine. Before running my exe, I have got 1.1 GB free memory. When I run the exe which is only one line you can find below, I am getting out of memory exception.
I am expecting the following line to use something around 600 Million Bytes. Does MemoryStream class use more memory than initalized capacity?
MemoryStream memory = new MemoryStream(600000000);
According to the following Q&A, it is likely that it is because your EXE is unable to allocate 600 megs of contiguous memory. ( I was trying to find something in the docs, this is the best I could come up with on short notice. )
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1af59645-cdef-46a9-9eb1-616661babf90
"An “out of memory” error almost never happens because there’s not enough storage available; as we’ve seen, storage is disk space, and disks are huge these days. Rather, an “out of memory” error happens because the process is unable to find a large enough section of contiguous unused pages in its virtual address space to do the requested mapping."
Interestingly, that answer linked to Eric Lippert's blog post: http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx
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