android-lru-cache

When should I recycle a bitmap using LRUCache?

邮差的信 提交于 2019-11-27 06:12:35
I'm using an LRUCache to cache bitmaps which are stored on the file system. I built the cache based on the examples here: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html The problem is that I'm seeing OutOfMemory crashes frequently while using the app. I believe that when the LRUCache evicts an image to make room for another one, the memory is not being freed. I added a call to Bitmap.recycle() when an image is evicted: // use 1/8 of the available memory for this memory cache final int cacheSize = 1024 * 1024 * memClass / 8; mImageCache = new LruCache<String, Bitmap>

Example using Androids lrucache

≯℡__Kan透↙ 提交于 2019-11-26 15:20:59
问题 I need help understanding androids LruCache. I want to use to load images into my gridview in order make the loading/scrolling better. Can someone post an example code using LruCache please. Thanks in advance. 回答1: Below is a class I made for using LruCache, this is based on the presentation Doing More With Less: Being a Good Android Citizen given at Google I/O 2012. Check out the movie for more information about what I'm doing in the TCImageLoader class: public class TCImageLoader implements

When should I recycle a bitmap using LRUCache?

喜你入骨 提交于 2019-11-26 11:54:35
问题 I\'m using an LRUCache to cache bitmaps which are stored on the file system. I built the cache based on the examples here: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html The problem is that I\'m seeing OutOfMemory crashes frequently while using the app. I believe that when the LRUCache evicts an image to make room for another one, the memory is not being freed. I added a call to Bitmap.recycle() when an image is evicted: // use 1/8 of the available memory for this