out of memory for load bitmap

开发一个app,有个背景图片20多k,然后发现在一些机器上oom,下面这个文章可以

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=326692988&siteId=291194637