Android: Out of memory (VM budget...) on startup, on small percent of total installs
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 applicat开发者_如何学编程ions 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 ?
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.
精彩评论