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 largeHeap="true" ... >
  1. Recycle your bitmaps

After loading a bitmap, be sure to recycle it and free up memory:

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 BitmapOptions and inSampleSize.

See Android documentation for example

Feedback about page:

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



Table Of Contents