Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inBitmap only on rotating and cropping? #85

Closed
andaag opened this issue Aug 8, 2014 · 2 comments
Closed

inBitmap only on rotating and cropping? #85

andaag opened this issue Aug 8, 2014 · 2 comments
Labels

Comments

@andaag
Copy link

andaag commented Aug 8, 2014

Hi

I've had a few experiments with inBitmap, attempting to use it without turning my codebase unmaintainable. When I saw glide I had hoped you had solved this issue in a neat library.

However, it seems inBitmap is only used when rotating and cropping an image? Is that a intentional technical decission, or can we expect some work to use inBitmap elsewhere as well?

@sjudd
Copy link
Collaborator

sjudd commented Aug 9, 2014

Hey, thanks for the question.

Glide attempts to retrieve and re-use a bitmap from the bitmap pool before allocating one in all of the operations it performs, not just rotations and transformations. In particular, Glide does set inBitmap whenever it uses the BitmapFactory interface. There are a few caveats related to platform support for bitmap reuse and various image types (see http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inBitmap). You can see the code in Glide where we re-use bitmaps with BitmapFactory here: https://github.com/bumptech/glide/blob/master/library/src/com/bumptech/glide/resize/load/Downsampler.java#L124.

If you've found a place where you think Glide isn't re-using a Bitmap, please point it out to me. It's almost certainly a bug and definitely something I'd like to fix.

@andaag
Copy link
Author

andaag commented Aug 10, 2014

I just did a quick test enabling logging on the LruBitmapPool class, and found it was never using put.

I just figured it out though. Testing this with my inBitmap code I've used "going into a page with huge images in it" as a quick way to fill the cache and ensure bitmaps are released for inBitmap. However it seems these images are now downsampled a lot (which is most likely a bug in my code somewhere, not in yours), so it didn't fill the memory cache.

Sorry about the noise! And thanks for this library.. As I mentioned I have done bitmap recycling before, and getting that done right + ending up with a elegant api is very impressive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants