Reputation: 278
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?
Upvotes: 7
Views: 6872
Reputation: 5407
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
Upvotes: 12