Is there any way to handle OutOfMemoryException in Android while using Bitmap of large number of pictures. I tried all the solutions given in this site ie(GC, Bitmap.reset()). I just want to know whether any alert can be generated before the heap memory is going to full? so that i can handle it in a different way.
-
2Just a note: never ever catch OutOfMemoryException. That can lead to totally unexpected behaviour and is considered a bad practice.bezmax– bezmax2011-03-14 09:24:23 +00:00Commented Mar 14, 2011 at 9:24
Add a comment
|
1 Answer
In your Activity there is a callback function you can implement to be notified of low memory issues:
http://developer.android.com/reference/android/content/ComponentCallbacks.html#onLowMemory()
@Override
public void onLowMemory() {
super.onLowMemory();
// Your memory releasing code
}