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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With