Android: “java-lang-outofmemoryerror-bitmap-size-exceeds-vm-budget-android” While loading bitmaps from sdcard?

前端 未结 1 1514
感动是毒
感动是毒 2021-01-16 20:44

In my application I have to display an image which is about 10000 x 5000 , using small images of 500x500 px. I.e;thru tiling images. In order to tile all images to one ini

相关标签:
1条回答
  • 2021-01-16 21:00
    1. Never load any tiles that you don't need. "am collecting all bitmaps from sdcard" suggests that you are decompressing every image you might ever need, which would be the wrong approach.

    2. Use smaller tiles. 256x256 is a good size.

    3. Load them as Config.RGB565 (i.e. 16bpp).

    4. Regularly recycle() Bitmaps you don't need.

    Basically you need to implement some sort of most-recently-used (MRU) Bitmap cache.

    0 讨论(0)
提交回复
热议问题