OutOfMemoryException in .NET (on 32 bit)
Posted by Vakul Kumar More on July 29, 2009
When I got an out of memory exception in my early days of programming, I believed that there is no memory for the program or process to use.
Now, when I started using High end PCs with 4 gigabytes of RAM, I am facing the same problem.
I realize now that memory is not the case but the common language runtime(CLR) throws an OutOfMemoryException error if it cannot allocate physical memory or reserve sufficient virtual memory to fulfill allocation request.
I tried to understand two concepts before further going into the explanation, the operating system manages processes, and the operating system manages files on disk.
Each process can access as much as data storage it wants. It asks the operating system to create for it a certain amount of data storage, and the operating system does so.
I understand that even if we have 512 MB of memory of 8 GB when running a 32 bit operating system no one process is going to get more than 2GB of RAM.
Eric Lippert has written a blog post on “Out Of Memory” Does Not Refer to Physical Memory. Click here for the blog post.
Robert L. Bogue has written in more detail in his post , What does an OutOfMemoryException in .NET (on 32 bit) really mean? Click here for the post.
Happy Coding !!