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
1
vote
1 answer

Android lrucache

I used the code android lrucache example (Memory Cache) to cache downloaded images(total nearly 120 kbytes) and it works, but when I go out from the activity(or app) the cache is removed, and when i again go to the activity it downloads and caches…
user3756319
1
vote
1 answer

LRUCache not working as expected

following example shows that using an limited sized LRUCache results in a OutOfMemory Error when allocating new space outside of the LRUCache. Properties: 64MB Process Size ; 10MB LRUCache Size ; 1MB chunks that I put into the LRUCache in a loop.…
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
1
vote
2 answers

Bitmap recycling is not working on android 4.2 or above 4.2?

I am using the below LRU class to manage bitmaps, using these two classes I am creating and removing bitmaps to put them on viewpager views. The same code is working on below 4.2 versions but when I load my app on 4.2 or above that than the heap…
Ujjwal Bansal
  • 289
  • 1
  • 4
  • 24
1
vote
2 answers

Android best way of caching images

I am making an attempt to build the most efficient way of caching images downloaded from the web for my app, a few years ago I tried to do this and could not find an efficient method of making this work until I stumbled upon the lazylist adapter…
Edmund Rojas
  • 6,376
  • 16
  • 61
  • 92
1
vote
0 answers

How to store bitmaps with 400kb size into LRUCache in android

On Clicking item on listview i am getting image from sdcard and I am storing into LRUCache. The image is of 400kb size with 750*580. But while retrieving the bitmap from cache the bitmap is null. Here is my code: Here lv is the listview and…
user1065434
  • 711
  • 1
  • 6
  • 10
1
vote
1 answer

Draw over Asset png efficiently and cache

I’m using thquinn’s DraggableGridView and load ~60 images into it. This all works fine. I had all the images needed in my assets, but want to create them at runtime since first of only the Text on the images change which seems redundant and I can…
M4tchB0X3r
  • 1,531
  • 1
  • 15
  • 28
1
vote
1 answer

Using LruCache to Store Bitmap in Memory

I have been trying to implement LruCache in my app but I have difficulties connecting the dots and passing Bitmaps between the different components. I would like to know how to integrate LruCache in my app. I am also looking to understand the…
user2510952
  • 193
  • 1
  • 3
  • 12
1
vote
1 answer

SimpleDiskCache inputStream bad number format

I'm using the SimpleDiskCache code (github link) to cache a few video files to disk for an Android app I'm working. Here's how I put the video file to cache: OutputStream fil = …
Alin
  • 1,044
  • 6
  • 20
  • 42
1
vote
2 answers

Is it a good idea to store LRUCache object in an Application singleton?

I have an LRUCache that I use to cache thumbnails and other such small bitmaps. Currently, I'm using it in my main activity, however, I'd like to use it my other activities too. This makes me wonder if it's a good idea to simply store this LRUCache…
A Random Android Dev
  • 2,691
  • 1
  • 18
  • 17
1
vote
1 answer

Memory-Leaks Image-Gallery Android - How can other applications handle it?

i'm trying to implement a image gallery, which should show ~ 5-15 smaller images and one "current selected" bigger image. It looks like: http://www.mobisoftinfotech.com/blog/wp-content/uploads/2012/06/galleryDemo.png I've looked up many sources and…
Frame91
  • 3,670
  • 8
  • 45
  • 89
1
vote
1 answer

can't add items to lrucache

I'm trying to use an LRUcache to cache some images that my app downloads from web. I've read the tutorial from android developers but i can't manage to add anything at my LRUcache. here is my code, class myloader extends Activity{ String…
tasgr86
  • 299
  • 2
  • 7
  • 17
1
vote
1 answer

Lru Cache listView image issues

I've my ListView with images on my activity, works great till I add the LRU Cache. When I load for the first time (if i don't scroll it) while the images are loading the first element change its image between all the images i was loading. My LRU…
norman784
  • 2,201
  • 3
  • 24
  • 31
1
vote
1 answer

Android Lrucache reference/object duplicated or not?

I want to increase my Apps speed and avoid heavy calls to the server by applying Android LruCache. Here is my scenario : I've create 2 LruCache objects. private LruCache> mListItemsCache; private LruCache
Van Vu
  • 11
  • 3
1
vote
2 answers

Cache small bitmaps from database

When my application connects to the server I check which icons are outdated or missing. I store those icons in a sqllite database, the icons aren't very big, around between 5-10kb. Everytime an activity starts, I'll go to the database and get the…
Robby Smet
  • 4,649
  • 8
  • 61
  • 104
0
votes
0 answers

LruCache in unit test return null

It's a bit wired when init Lrucache, it throws NullPointerException. The code is: @Test fun testLruCache() { try { val code = "code" val cache: LruCache = LruCache(1000) println(cache) …
William Hu
  • 15,423
  • 11
  • 100
  • 121