MemoryError (Unable to allocate X GiB for an array)
Python couldn’t allocate memory — the data is larger than available RAM or address space.
Unable to allocate 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
- Process in chunks (pd.read_csv(chunksize=...))
- Use smaller dtypes (float32, category)
- Install 64-bit Python
- Use generators instead of lists
Detailed fix by platform
Python
for chunk in pd.read_csv("big.csv", chunksize=100_000): process(chunk)
How to diagnose
- Size — How large is the data vs RAM?
- 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:
Similar errors
Most viewed in Python
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 15 Oct 2026