caching - Android Bitmap Cache -


i'm working on implementing cache lot of bitmap tiles have. i've done far:

successfully implemented lru cache system, tiles still load when must loaded app's resources. cache has 85% hit rate.

whenever must load bitmap resources, still slow said. in mind, loading bitmaps async task. before this, load without error, slow. now, it's faster since it's not working on main thread, inevitably run oom error. here's code async task:

public class loadbitmap extends asynctask<void,void,void> {     bitmap bit;     @override     protected void doinbackground(void... params)      {         options opts = new options();         bit = bitmapfactory.decoderesource(reso, drawable, opts);         return null;     }      @override     protected void onpostexecute(void result)      {         // todo auto-generated method stub         drawloadedbit(bit);         super.onpostexecute(result);     } } 

any ideas on how can implement don't out of memory error? since called in draw method, i'm thinking multiple calls causing it. advice.

refer link

he gives tutorial on using regenative bitmaps. further, decouple bitmap view [once view disposed], can @override view#onremovedfromwindow() recycle bitmap. going further, if still have issue, can create bitmappool in allocate bitmaps. can implement algorithm go calculate sizes of bitmaps , release older bitmaps push on arbitrary memory amount (bitamp memory width*height*4 + object size should nominal)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -