MemoryError Python Origin: Application & API Last updated 15 Oct 2026

MemoryError (Unable to allocate X GiB for an array)

Python couldn’t allocate memory — the data is larger than available RAM or address space.

Exact message you may see Unable to allocate
Seen on: Python

Meaning

NumPy/pandas raise “Unable to allocate X GiB for an array with shape …”. 32-bit Python is limited to ~2–4 GB regardless of RAM.

Common causes

  • Loading a huge file fully into memory
  • Creating giant arrays/matrices
  • 32-bit Python
  • Memory leak in long loops

⚡ Quick fix

  1. Process in chunks (pd.read_csv(chunksize=...))
  2. Use smaller dtypes (float32, category)
  3. Install 64-bit Python
  4. Use generators instead of lists

Detailed fix by platform

Python

  1. for chunk in pd.read_csv("big.csv", chunksize=100_000): process(chunk)

How to diagnose

  1. Size — How large is the data vs RAM?
  2. Build — 32- or 64-bit Python?

🔧 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)0xC0000005Cannot allocate memory — fork: Cannot allocate memory / ENOMEM (Linux)Cannot allocate memorydouble free or corruption — C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped) (C/C++)double free or corrup…EXC_BAD_ACCESS — Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) (iOS)EXC_BAD_ACCESSGradle Java heap space — Gradle: Expiring Daemon because JVM heap space is exhausted / java.lang.OutOfMemoryError: Java heap space during build (Android)Gradle Java heap spaceheap out of memory — FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (Node.js)heap out of memoryinvalid string length — RangeError: Invalid string length (JavaScript)invalid string lengthJupyter kernel died — The kernel appears to have died. It will restart automatically. (Python)Jupyter kernel diedMemoryErr…

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.