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
3
votes
1 answer

How To Clear Androids LRUCache

In the API of Google Developer there is a trimToSize() Method, that I can't find / use. How do I clear or reduze the size of my LRU Cache ?
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
2
votes
1 answer

LruCache returns null

i have the following code to cache bitmaps , when i try to retrieve them using their key . They always return null . Please help me . Thank You final int memClass = ((ActivityManager)…
Sarthak Mishra
  • 1,033
  • 1
  • 11
  • 27
2
votes
2 answers

NullPointerException: key == null || value == null

I have a Adapter in my application which inflates posts and shows them in a ListView. Each post has an image, so it uses LruCache to store images. The app works well completely, but it crashed two or three times and I couldn't realize what was the…
Koorosh
  • 302
  • 1
  • 5
  • 15
2
votes
3 answers

Picasso - Limit cache size to 5 MB

I’m using Picasso in my app for download and cache images. its Work great but there is a problem : app has a lot of images and after a short time app cache increase over 10 MB ! after long search I found this solution for limiting cache in Picasso…
YFeizi
  • 1,498
  • 3
  • 28
  • 50
2
votes
0 answers

LRUCache returns size 0 until all images have been cached

I'm using LRUCache to cache images that I retrieve from a server. I'm requesting them from a RecyclerView but till all the images are cached the LRUCache instance returns size 0. Here's the Code public void buildCache() { for (Feed feed :…
2
votes
0 answers

How to Create custom google marker using lru cache in android?

Hi can anyone give sample code to create a custom google marker using lru cache.I don't know how to reuse the bitmap and clear the cache while exceeds the memory.
2
votes
2 answers

Is it possible to change the size of the cache Picasso uses for images?

I'm loading images from URLs (http://) with Picasso. Sometimes when i try to "preload" an image using Picasso's fetch() method, the image doesn't get cached. I guess it's because it's size is too big. Read the answer for this question, but…
anon
2
votes
1 answer

Implementing Image Lru Caching with DiskLruCache

I am trying to implement Disk based image lru cache with jake wharton DiskLruCache library. link to library. I am using a code snippet from here. Methods i am having trouble with are this private boolean writeBitmapToFile(Bitmap bitmap,…
ddog
  • 670
  • 1
  • 10
  • 25
2
votes
2 answers

Android: LruCache issue with Bitmap

I have a global bitmap cache using LruCache class. when loading thumbnails for the listview, the cache is used first. It works just OK. But one issue is: sometimes the Bitmap instance from the cache cannot be displayed on the listview. it seems…
Martin Lau
  • 219
  • 3
  • 13
2
votes
4 answers

How to prevent Out of memory error in LRU Caching android

I have used Memory LRU Caching for caching bitmaps in my android application.but after some of the bitmaps are loaded into LRU map app force closes saying out of memory exception. I have spent whole day behind this but yet not found the solution…
Ravi
  • 93
  • 3
  • 11
2
votes
0 answers

Android LRU cache not caching on gingerbread

I've used LRU cache for caching bitmap images. I used typical code for implementing those, and it works fine on Ice Cream Sandwich. However, the caching process doesn't work on Gingerbread. Here is a my code: import…
lancif
  • 737
  • 1
  • 8
  • 17
2
votes
3 answers

android: LruCache return null

I am new to LruCache in android and i want to put and get bitmap images (JPEG) on this cache to prevent memory errors and memory exception, so i can't understand why my code does not work. here is my code: ImageView imageview =…
2
votes
1 answer

LRU cache with objects that should not be removed

I use an LRU cache (LruCache class from android.util) in my Android app. which is generally working fine. Now I have a special requirement for this LRU cache: I would like that some objects are never removed. Explaining the situation: I have an…
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
2
votes
0 answers

Preferred way to use LruCache: big singleton or many small?

Is it preferred to use a big LruCache as a singleton globally in the app where all images are cached or is it preferred to use several smaller LruCache at different places in the app?
Simon Zettervall
  • 1,764
  • 1
  • 15
  • 31
2
votes
1 answer

Using LruCache and avoid OutOfMemoryException

There's an activity in my app whose showing around 1000 very small sized bitmaps (Around 20kb each bitmap). After it loads some of the bitmaps, there's an OutOfMemoryException. I was first reading about SoftReference and it looked like it will solve…
idish
  • 3,190
  • 12
  • 53
  • 85