I'm using Glide to load bitmaps to create a gif.
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 recycling this Bitmap or putting it back in the Glide BitmapPool? There doesn't seem to be a way for Glide to re-use it automatically or by using clear()
.
I looked at adding the Bitmap back to the Pool directly using something like Glide.get(context).getBitmapPool().put(img)
but according to the documentation using the BitmapPool directly can lead to undefined behaviour.