0

I get a clasical "VM budget excedees memory - out of memory" type error crash report from the Android Market.

I checked the app for memory leaks over and over again. This error happens on a very small percent of total application installs, around 1-2% and it always happens on start-up. The app loads some bitmaps from internal memory for each activity, but does not crash on most devices. I thought all applications had a guaranteed minimum stack size for bitmaps so this should work for every device. Min SDK is 7.

Any reason why ? Does this sound familiar to anyone ?

Flav
  • 1
  • http://stackoverflow.com/questions/3037027/android-outofmemoryerror-bitmap-size-exceeds-vm-budget-with-no-reason-i-can-see http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue – Samir Mangroliya Sep 14 '11 at 13:23

1 Answers1

0

I had quite a similar problem, and my images were simply too big for some devices.

I have read that you have one image per Activity and I guess this happens when switching from one to another as the newly allocated Drawable cannot fit. What you could do, to save some memory, would be to unload the background image of the Activities that are not shown:

@Override
protected void onResume() {
    super.onResume();

    Drawable d = loadMyDrawableFromDisk();
    setBackgroundDrawable(d);
}

@Override
protected void onPause {
    setBackgroundDrawable(null);

    super.onPause();
}

It may help as the memory will be freed a few after onPause() is called, and not when the underlying View of your Activity will be unallocated by the system.

Shlublu
  • 10,917
  • 4
  • 51
  • 70