-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Trim and clear memory cache #35
Conversation
public void trimMemory(int level) {} | ||
|
||
@Override | ||
public void trimToSize(int size) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only want to expose either trimMemory or trimToSize as part of the external interface (probably just trimMemory so we don't need to keep track of the pool's size outside of the pool?).
Other than a couple of comments LGTM. In the long run we probably want to add similar functionality to the BitmapPool and add a similar interface (trimMemory(int level)) to ImageManager and then we can use the Glide singleton to call into the ImageManager rather than having to expose the cache and the pool. This is a great start though, thanks! |
How about now? |
Looks good, thanks! |
how about Runtime.getRuntime.freememory and use a default memory trimmer if freememory is as per the ontrimmeory levels ? |
I think Runtime.getRuntime.freememory isn't really accurate. It looks like it gives you the amount of free memory out of the memory that is currently allocated, not out of the maximum that can be allocated. If you have 22mb allocated, and are using 21mb, freememroy would give you 1mb even if the maximum amount of memory you can use is 60mb. I found this helpful: http://stackoverflow.com/questions/3571203/what-is-the-exact-meaning-of-runtime-getruntime-totalmemory-and-freememory Or were you thinking of something else? |
Added methods that allow to clear and trim the memory cache