System.OutOfMemoryException was thrown


If your .NET application displays the 'System.OutOfMemoryException' error message, you might assume it is a server memory issue, but that is not the case.

The error is related to contiguous blocks of memory in a 32-bit process.

It is caused by:

  1. Your process is using too much memory (typically over 800 MB in a 32-bit environment).
  2. The virtual address space is fragmented, reducing the likelihood that a large, contiguous allocation will succeed.

This is explained in the following Microsoft support article:

When an application needs to use memory, it reserves a chunk of the virtual address space and then commits memory from that chunk. It is exactly what the .NET Framework's garbage collector (GC) does when it needs memory to grow the managed heaps. When the GC needs a new segment for the small object heap (where objects smaller than 85 KB reside), it makes an allocation of 64 MB. When it needs a new segment for the large object heap, it makes an allocation of 16 MB. These large allocations must be satisfied from contiguous blocks of the 2 GB of address space that the process has to work with. If the operating system is unable to satisfy the GC's request for a contiguous block of memory, a System.OutOfMemoryException (OOM) occurs.

https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/performance/troubleshoot-outofmemoryexception

The quickest way to get your website back online is to recycle the application pool. This will clear the address space.

It won't, however, solve the underlying issue. You can refer to this Stack Overflow article for more solutions on how to fix your website:

https://stackoverflow.com/questions/1153702/system-outofmemoryexception-was-thrown-when-there-is-still-plenty-of-memory-fr

 

 


Was this answer helpful?

Still need help?

Our friendly support team are ready to offer assistance with any issues you may be encountering.
Click the button below to open a ticket:
Open Ticket

 WordPress Hosting

Fast hosting for WordPress
Experience the best in Australian WordPress hosting with lightning fast servers, built-in caching, and performance tools.

 Build Your Website

Sitejet Hosting
Build your site fast with a drag and drop editor with no coding required. 140+ quality, templates to get you started.

 Register Domains

It all starts with your domain name
Find the perfect domain and register now with our competitive pricing on all extensions.

 Web Hosting

Fast, local, secure hosting
Full featured hosting on cPanel with multiple server locations around the country.
« Back