OutOfMemoryError

suggest change

This is a runtime error that happens when you request a large amount of memory on the heap. This is common when loading a Bitmap into an ImageView.

You have some options:

  1. Use a large application heap

Add the “largeHeap” option to the application tag in your AndroidManifest.xml. This will make more memory available to your app but will likely not fix the root issue.

<application android:largeHeap="true" ... >
  1. Recycle your bitmaps

When you are finished with a bitmap, recycle it to free native memory. Do not recycle a bitmap that an ImageView is still showing:

if (bitmap != null && !bitmap.isRecycled())
   bitmap.recycle();
  1. Load sampled bitmaps into memory

Avoid loading the entire bitmap into memory at once by sampling a reduced size, using BitmapFactory.Options and inSampleSize.

See the Android documentation for an example.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents