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

Consider dropping Bitmaps when View not visible #2520

Closed
shaybarak opened this issue Oct 26, 2017 · 4 comments
Closed

Consider dropping Bitmaps when View not visible #2520

shaybarak opened this issue Oct 26, 2017 · 4 comments

Comments

@shaybarak
Copy link

In many apps that I looked at, Bitmaps were the top contributor to RAM usage. Often times these Bitmaps are held by Views that are not visible, either because the app is not in the foreground, or because the View is tied to a Fragment that is currently not visible but also not destroyed.

I wonder if Glide could allow developers to specify that certain Views should aggressively release their Bitmaps when they're not visible, and re-inflate the Bitmaps when they become visible again.

@TWiStErRob
Copy link
Collaborator

Glide.clear()/Glide.with().clear() could help with this, as you know when the image becomes invisible/visible again.

I wouldn't worry about app not in foreground. Since each app has so little VM heap associated to it, there's no point in cleaning that up. It is all yours (and fully reserved to you, even if it's empty) until Android thinks to kill the whole process, at which point it doesn't matter any more how full your quota was.

@sjudd
Copy link
Collaborator

sjudd commented Oct 27, 2017

We actually used to do this in G+. It leads to a pretty substantial increase in grey squares/ui jank if users navigate back and forth between image heavy Activities. The image cache gets blown out quickly or has to be very large to make up for the difference.

It's a good idea as an option or on low RAM devices though if developers have control over when it happens.

sjudd added a commit to sjudd/glide that referenced this issue Nov 15, 2017
Also returns appropriate ViewTarget implementations from into(ImageView) so that the method can easily be chained.

Related to bumptech#2520.
@sjudd
Copy link
Collaborator

sjudd commented Nov 15, 2017

@shaybarak I have something that might work, though it's a bit of a hack in its current form. Let me know if you have someone in mind who'd be interested in trying it.

sjudd added a commit to sjudd/glide that referenced this issue Nov 15, 2017
Also returns appropriate ViewTarget implementations from into(ImageView) so that the method can easily be chained.

Related to bumptech#2520.
sjudd added a commit to sjudd/glide that referenced this issue Nov 19, 2017
Also returns appropriate ViewTarget implementations from into(ImageView) 
so that the method can easily be chained.

Related to bumptech#2520.
@sjudd sjudd closed this as completed Nov 20, 2017
@sjudd
Copy link
Collaborator

sjudd commented Nov 20, 2017

Added here: d0fd967

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

No branches or pull requests

3 participants