glide icon indicating copy to clipboard operation
glide copied to clipboard

Is Glide can automatic clean cache?

Open pengkshu opened this issue 11 years ago • 6 comments

I use Glide to load bitmap in RecyclerView, but I found the head size will increase, and the head size don't stable a certain level. It will oom?I want to ask that Glide will auto clean memory cache? (My English is pool,sorry.)

pengkshu avatar Sep 11 '15 09:09 pengkshu

It is subscribed to onLowMemory events, so the memory cache is pruned when the system asks for it.

Please note that if you display too many or large images cleaning the memory cache won't really help.

If memory pool (not cache) size increases it probably indicates that Glide cannot reuse Bitmaps because they are of different size, try to unify ImageView sizes in the list in this case.

TWiStErRob avatar Sep 11 '15 10:09 TWiStErRob

If memory usage just increases over time, it's likely that you have a memory leak in your application. Glide's memory cache and Bitmap pool both have fixed sizes, so even if you're not getting good hit rates in either, memory usage is still size bound.

sjudd avatar Sep 11 '15 15:09 sjudd

@sjudd hi, I also use Volley to load bitmap,the memory usage is stable a certain level(almost 30M). But if I use Glide, it will increases(almost 50M). Will Glide clean memory usage if bitmap memory usage is over a someone level?

pengkshu avatar Sep 14 '15 03:09 pengkshu

@TWiStErRob hi Glide.with(mContext).load(imageUrl).crossFade().override(114,114).into(imageView); This is how I use Glide in my app.I had set a certain sizes of bitmap. And imageView‘s property in xml is : android:layout_width="match_parent" android:layout_height="80dp" android:adjustViewBounds="true" android:scaleType="centerCrop"

pengkshu avatar Sep 14 '15 03:09 pengkshu

As mentioned above, Glide uses fixed size memory pools/caches so Glide's memory usage is capped. Glide's memory use is also reduced when memory ComponentCallbacks are called.

It's also entirely possible, and even probably that Glide uses more memory than Volley by default. If you'd like to reduce Glide's memory usage, see the Configuration page.

Again if your memory usage appears to be unbounded, I'd suspect a memory leak.

sjudd avatar Sep 14 '15 14:09 sjudd

@sjudd thinks!

pengkshu avatar Sep 15 '15 00:09 pengkshu