简体   繁体   中英

Efficient way to manage large array of bitmaps android

I have a question regarding the recommended/best practice for managing a large array of bitmaps. (It's a flipbook type app where the user goes through and creates new pages...like a virtual pile of sticky notes k?) Previously, I had an arraylist of objects that held bitmaps, (good performance) but I quickly ran into Out of Memory issues with the dalvik vm's heap limit.

I later tried storing the bitmaps not displayed on the screen to the sd card as cache and then grabbed them on demand, but I found this to be significantly slower on my phone than the previous method.

What is the best plan of attack for this problem?

Perhaps you could try a combination. Keep the bitmaps on sd card as cache and when bitmap "B" is loaded, you load bitmaps "A" and "C" into memory, where "A" and "C" are the bitmaps surrounding "B" in your app.

您应该同时使用强引用的内存缓存和磁盘缓存,请参阅Android培训类“ 有效显示位图” ,尤其是“ 缓存位图”课程。

One suggestion, If your bitmap is no longer usable or you want to remove it from memory. You should do,

bitmapObject.recycle();

It is the best efficient way to release bitmap memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM