glide icon indicating copy to clipboard operation
glide copied to clipboard

Relationship between BitMapPool, MemoryCache and DiskCache?

Open MNDaveC opened this issue 10 years ago • 2 comments

What is the relation between BitMapPool, MemoryCache and DiskCache? is one a subset of the other? how should their sizes be comparatively? The default suggestions I got from the calculator produced 29mb for cache and 58mb for bitmap pool.

When profiling my app, I see memory usage jump by 100MB when loading a RecyclerView that has up to 30 images of approx 350-400 kb each at the source. Can I restrict cache sizes to contain the 100MB spike in memory? Any other suggestions to contain the memory usage?

Glide Version: 3.7.0

Integration libraries: okhttp3-integration:1.4.0

Device/Android Version: Galaxy S7

Issue details / Repro steps / Use case background: Occasional OOM

Glide load line / GlideModule (if any) / list Adapter code (if any):

    Glide.with(imageView.getContext())
            .load(imageItem.imageUrl())
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .placeholder(placeholder)
            .crossFade()
            .dontAnimate()           //Avoids flicker
            .listener(new RequestListener<String, GlideDrawable>() {
                @Override
                public boolean onException(Exception e,
                                           String model,
                                           Target<GlideDrawable> target,
                                           boolean isFirstResource) {
                    // Don't set the tag here in case we want to retry on the next call to notify
                    // the adapter.

                    // Always clear the placeholder
                    mHeroImagePlaceholderDrawable = null;
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource,
                                               String model,
                                               Target<GlideDrawable> target,
                                               boolean isFromMemoryCache,
                                               boolean isFirstResource) {
                    // Set the image URL as a tag so we know that the image with this URL has
                    // successfully loaded
                    imageView.setTag(imageItem);

                    // Always clear the placeholder
                    mHeroImagePlaceholderDrawable = null;
                    return false;
                }
            })
            .into(imageView);

Layout XML:

<FrameLayout xmlns:android="...

Stack trace / LogCat: Occasional OOM

MNDaveC avatar Nov 16 '16 18:11 MNDaveC

I have the same problem and I open a new issue as well. Glide load with recyclerview results in memory leak.

Ron-lab avatar Dec 29 '16 08:12 Ron-lab

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

stale[bot] avatar Nov 12 '17 07:11 stale[bot]