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
Bitmap recycling not implemented #114
Comments
Recycling requires much more infrastructure than that. You have to keep reference counts manually and recycle when it returns to zero. That becomes increasingly hard to do when we expose the raw Bitmap through the Target interface for custom views to implement. Consumers would have to manage incrementing and decrementing the reference count themselves. Considering most don't even use the Target interface correctly I don't think many would use reference counts correctly either. Additionally, we keep an LRU cache of Bitmap instances for quick loads of the most used images. We can't even recycle when a Bitmap is purged from the LRU because there is no guarantee that it still isn't being used on the screen. There's simply too much going on to recycle explicitly. We defer to appropriately sized memory caches and the normal garbage collector for this. |
I agree with the fact that recycling would require more effort on writing extra code. I do not agree with the fact that reference counting must be done by consumer code. It is fairly easy to implement a Bitmap recycler. It must extends ImageView and override onDetachedFromWindow method. Also, the overloaded ImageView class must be aware of cache object and correctly dereference the contained Bitmap from the cache when being destroyed. |
The whole point of the memory cache is to keep images when they are not being displayed, not remove them. This allows quick subsequent loads of the same image. If you are loading full-screen bitmaps for display once you should try the |
in android 2.3, if do not call recycle, is it memory leak? |
From what I can see the library does not provide recycling of Bitmap objects. I miss a class extending ImageView that does that. Any chance for adding support for that?
The text was updated successfully, but these errors were encountered: