When downloading Bitmap using Glide, who is responsible for processing it?

I use Glide to upload bitmaps to create gifs.

for (int i = 0, count = files.size(); i < count; i++) { Bitmap img = Glide.with(context) .load(files.get(i)) .asBitmap() .centerCrop() .into(GIF_EXPORT_SIZE / 2, GIF_EXPORT_SIZE / 2) .get(); // addFrame creates a copy of img, so we can re-use this bitmap encoder.addFrame(img); } 

I was wondering who is responsible for processing this bitmap or returning it to Glide BitmapPool? It seems that Glide cannot reuse it automatically or using clear() .

I looked at adding Bitmap back to the pool directly using something like Glide.get(context).getBitmapPool().put(img) , but according to the documentation using BitmapPool, it can directly lead to undefined behavior.

+5
source share
1 answer

According to their wiki, Resource Reuse: Like , you don't need to recycle since Glide does this, but based on the amount of resources.

When the reference count drops to zero, Glide will recycle the resource and return its contents to any available pools.

Although you will need to explicitly call Glide.clear () to reduce the amount of resources, since glide can only call Glide.clear () when replacing an image of an existing target / view. Hope this helps.

0
source

All Articles