7

I create bitmap drawables from large images and OutOfMemory error occures at that time. Activity.onLowMemory() method should be called but actually it is not called by framework.

Is there any solution of this, or is there any other way to capture OutOfMemory error in android?

Hardik Muliya
  • 278
  • 3
  • 9
  • 2
    `onLowMemory` is called when the *entire system* is running low - your own application chewing through its available memory isn't considered a reason for the rest of the system to start tightening its belt. – Jens May 07 '12 at 14:13

1 Answers1

12

That is not how onLowMemory works. It will be called when the whole System runs low on memory, not your App, so you can't exactly avoid OOMs with it. More Details here.
Also see a blog post from Romain Guy for some more Info about memory leaks: links

At least there are hundreds of Questions how to handle Bitmaps here on Stackoverflow:

Android Bitmap Memory Leak, what to do more
Bitmap, Bitmap.recycle(), WeakReferences, and Garbage Collection
Android custom view Bitmap memory leak

Sulfkain
  • 5,082
  • 1
  • 20
  • 38
Thommy
  • 5,070
  • 2
  • 28
  • 51