The public void onLowMemory () function is not called by the Android infrastructure when the OutOfMenory system starts

I am creating bitmap images from large images and an OutOfMemory error occurs at that time. The activity.onLowMemory () method should be called, but in fact it is not called by the infrastructure.

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

+5
source share
1 answer

This is not how onLowMemory works. It will be called when there is not enough memory in the whole System, and not for your Application, therefore, you will not be able to accurately avoid using OOM. More details here .
Also see the Romain Guy blog post for more information on memory leaks: links

At least there are hundreds of Questions about how to handle bitmaps here in Stackoverflow:

Android Bitmap memory leak, what to do next
Bitmap, Bitmap.recycle (), WeakReferences and Android garbage collection
custom view Bitmap memory leak

+8
source

All Articles