Questions tagged [android-lru-cache]

LruCache holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible for garbage collection.

LruCache holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible for garbage collection.

109 questions
56
votes
2 answers

When should I recycle a bitmap using LRUCache?

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…
howettl
  • 12,419
  • 13
  • 56
  • 91
43
votes
5 answers

Example using Androids lrucache

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.
MobDev
  • 1,219
  • 1
  • 12
  • 25
12
votes
1 answer

How to implement an in Memory Image Cache in Android?

Until now I'm using a SoftReference Cache for images in Android. This cache is used for images that are shown in ListViews and should help holding images of items in memory that are not shown on the screen, if there is enough memory left. The…
Janusz
  • 187,060
  • 113
  • 301
  • 369
8
votes
2 answers

LRUCache entry reordering when using get

I checked out official Android documentation for LRUCache which says : Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible…
gaurav jain
  • 3,119
  • 3
  • 31
  • 48
7
votes
3 answers

LruCache not working

final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cacheSize = maxMemory / 8; mMemoryCache = new LruCache(cacheSize) { @Override protected int sizeOf(String key,…
Faceles
  • 453
  • 1
  • 5
  • 16
6
votes
2 answers

Android LruCache cache size parameter

I am trying to follow a 2 year old tutorial on android regarding the usage of LruCache and some samples I have googled so far have the same method which is to pass an value(int) that is converted to KiB. final int maxMemory =…
Rei
  • 761
  • 1
  • 7
  • 17
6
votes
1 answer

developer.android.com/training bitmapfun project

I am using bitmapfun project (gridview) in my application and while i was testing this i found a problem. The steps to reproduce this problem are the following: Open wifi -> launch app -> download images (It works fine). Close app (back button),…
5
votes
3 answers

Android LRUCache Retrieval

I have implemented a standard LRUCache in Android that stores Objects. Each key is a unique ObjectId associated with the Object stored. My problem is that the only way to retrieve an Object from cache is by the ObjectId (no iterator). What would be…
Nelson.b.austin
  • 3,080
  • 6
  • 37
  • 63
5
votes
1 answer

Why is android.util.LruCache.* not found when using android-support-v4?

I am writing a project that uses LruCache, which is included in the android-support-v4.jar compat library. When running on devices with JB, the code works fine, but when I run it on my Droid X with GB, the app dies with the following…
4
votes
0 answers

Cache Data Using Lru Cache In Android

I am trying to cache some data using LruCache in android, say like I have LruCache And SomeDataClass like data class SomeDataClass(val data: Any) My doubt is if am pushing some data to the cache and by the time cache is…
Stack
  • 1,164
  • 1
  • 13
  • 26
4
votes
3 answers

NoSuchMethodError using LruCache in Android

I'm having an error using a custom class that inherits from LruCache in Android. It's supposed to download images and cache them; yesterday, it was working, but this morning I run into this issue. This is the code of the class: public class…
noloman
  • 11,411
  • 20
  • 82
  • 129
3
votes
1 answer

Use LRU Image Caching In Conjuction With HTTPResponseCache for Disk and Memory Caching

Initially the objective was to use both disk and memory cache. This would require implementing LRU cache and DiskLruCache. However, since HTTPResponse cache uses disk space, I chose to use LRU cache and do con.setUseCaches(true); The problem is…
3
votes
1 answer

FFmpeg output seeking result to Android LruCache

Dear fellow StackOverflower, In my Android application, I'm trying to quickly retrieve a frame from a video using ffmpeg-android-java to display in an ImageView. The problem is using a typical ffmpeg's -ss seeking command will require to write the…
vxh.viet
  • 388
  • 5
  • 21
3
votes
0 answers

Using disk cache with Volley and ListView really slow

I am trying to use this library https://github.com/JakeWharton/DiskLruCache for disk cache but I'm having problems when I have a lot of images in my ListView. The lag is really bad sometimes. I've used the following approach like from this GitHub…
user4386126
  • 1,205
  • 5
  • 17
  • 32
3
votes
0 answers

iitialize ImageCache from the context of an activity

I try to understand this sample to match with mine:(DisplayingBitmaps) http://developer.android.com/downloads/samples/DisplayingBitmaps.zip This code uses the class ImageCache that manages the caching of bitmaps: public class ImageCache { private…
Aristide13
  • 244
  • 2
  • 16
1
2 3 4 5 6 7 8