I have a scrollable map app which for now has a huge bitmap. It loads fine on startup, but when it looses foreground status and the user brings it backs again im getting an out of memory error. In onPause it trashes the bitmap using recycle, and marks it as null. The onResume checks to see if map==null and will load the bitmap back again, which is crashing the program despite me recycling the bitmap...Here are some bits of code. All of the other references to Bitmap map first check if it is null before loading/drawing.
onPause
protected void onPause() {
super.onPause();
Log.e("sys","onPause was called");
if (map != null)
{
map.recycle();
map = null;
System.gc();
Log.e("sys","trashed the map");
}
}
my onResume
protected void onResume(){
super.onResume();
Log.e("sys","onResume was called");
if (map == null)
map = BitmapFactory.decodeResource(getResources(),
R.drawable.lowresbusmap);
Log.e("sys","redrew the map");
}