OutOfMemoryError: Failed to allocate a bitmap allocation Android Origin: On your device OSI layer 7 · Application Last updated 25 Nov 2026

java.lang.OutOfMemoryError: Failed to allocate a 33177616 byte allocation with 16777216 free bytes

Loading a large image consumed more memory than the app may use.

Exact message you may see OutOfMemoryError Failed to allocate a byte allocationOutOfMemoryError bitmapFailed to allocate a with free bytesjava.lang.OutOfMemoryError: Failed to allocate a 33177616 byte allocation with 16777216 free bytes and 28MB until OOM, target footprint 134217728, growth limit 134217728
Seen on: Android

Meaning

Decoding full-resolution photos into Bitmaps is the usual cause. Downsample with inSampleSize, use Coil/Glide/Picasso, and avoid keeping many large bitmaps in memory.

Common causes

  • Full-size bitmaps decoded for thumbnails
  • Bitmaps leaked in static fields
  • Large images in drawable-nodpi

⚡ Quick fix

  1. Use Coil/Glide with size hints
  2. Downsample with BitmapFactory.Options
  3. Recycle or release references

Detailed fix by platform

Kotlin

  1. imageView.load(uri) { size(1080, 1080) } // Coil

How to diagnose

  1. Size — decoded size?
  2. Library — image loader?
  3. Leak — heap dump?

🔧 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: On your device. 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)0xC0000005ANR — ANR: Application Not Responding (Input dispatching timed out) (Android)ANRAsyncImage stuck on placeholder in Compose — (behavior) Coil AsyncImage never replaces the placeholder (Android)AsyncImage stuck on p…Cannot allocate memory — fork: Cannot allocate memory / ENOMEM (Linux)Cannot allocate memoryCoil: ImageRequest failed / SuccessResult expected — coil.request.ErrorResult: java.net.UnknownHostException (Android)Coil: ImageRequest fa…Container exceeded memory limit — Bitbucket Pipelines: Container 'Build' exceeded memory limit / Docker container exited with code 137 (CI/CD)Container exceeded me…CursorWindow: Window is full: requested allocation bytes — android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed (Android)CursorWindow: Window …EXC_BAD_ACCESS: message sent to deallocated instance — -[Foo bar]: message sent to deallocated instance 0x600000 (iOS)EXC_BAD_ACCESS: messa…OutOfMemo…

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.