out of memory for load bitmap

Develop an app with a background image of more than 20k, and then found that oom on some machines, the following article can be

http://stackoverflow.com/questions/14359024/out-of-memory-error-while-loading-bitmaps

https ://developer.android.com/training/displaying-bitmaps/cache-bitmap.html

https://developer.amazon.com/appsandservices/solutions/devices/kindle-fire/specifications/01-device-and-feature- specifications

https://developer.android.com/training/displaying-bitmaps/load-bitmap.html

I had the similar problem while displaying high resolution images. I have searched and applied all the android bitmap solutions given in http://developer.android.com/training/displaying-bitmaps/index.html and the following caches mekanism in the link. but none of them work. not any right solution anywhere. Then I figured out that the problem is : I couldnt use the drawable folder structure right. I was keeping high resolution images in mdpi and hdpi folders . this cause android scale up the images to the ultra sizes. 100 kb image was causing 20 mb increase in memory thanks to the android monitor / memory section. so I have added these ultra resolution images to xxhdpi folder , then It was FIXED suddenly. then my image slider work flawlessly

Heap size (large)
android:largeHeap="true"

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326693016&siteId=291194637