OutOfMemoryException .NET Origin: Application & API Last updated 12 Oct 2026

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown

The process couldn’t allocate memory — large in-memory data, leaks, 32-bit process limits, or container memory limits.

Exact message you may see Exception of type 'System.OutOfMemoryException' was thrownInsufficient memory to continue the execution of the program
Seen on: .NET

Meaning

Loading whole files/tables into memory, huge strings/StringBuilders, caching without limits, or running as 32-bit (Prefer 32-bit) cause it. In containers the GC heap limit follows the memory limit.

Common causes

  • Loading large datasets/files fully into memory
  • Memory leak (static caches, event handlers)
  • 32-bit process (Prefer 32-bit)
  • Container memory limit

⚡ Quick fix

  1. Stream data (IAsyncEnumerable, FileStream)
  2. Use dotnet-counters/dotnet-dump to find what grows
  3. Build as 64-bit; raise container limit if justified

Detailed fix by platform

Shell

  1. csharp
    dotnet-counters monitor -p <pid> System.Runtime
    dotnet-dump collect -p <pid>

How to diagnose

  1. Growth — GC heap over time
  2. Bitness — 32-bit?
  3. Limits — Container memory

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0xC0000005 — The application was unable to start correctly (0xc0000005) / Exception code 0xc0000005 access violation (Windows)0xC0000005103 — HTTP 103 Early Hints (HTTP)1031200 — Cloudflare Error 1200: Cache connection limit (Cloudflare)1200304 — HTTP 304 Not Modified (HTTP)304504 — HTTP 504 Gateway Timeout (HTTP)504524 — Cloudflare Error 524: A Timeout Occurred (Cloudflare)52457014 — ERROR: canceling statement due to statement timeout (PostgreSQL)57014ANR — ANR: Application Not Responding (Input dispatching timed out) (Android)ANROutOfMemo…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.