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

Trim and clear memory cache #35

Merged
merged 4 commits into from
Nov 7, 2013

Conversation

savvasdalkitsis
Copy link
Contributor

Added methods that allow to clear and trim the memory cache

@savvasdalkitsis savvasdalkitsis mentioned this pull request Nov 6, 2013
public void trimMemory(int level) {}

@Override
public void trimToSize(int size) {}
Copy link
Collaborator

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?).

@sjudd
Copy link
Collaborator

sjudd commented Nov 6, 2013

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!

@savvasdalkitsis
Copy link
Contributor Author

How about now?

@sjudd
Copy link
Collaborator

sjudd commented Nov 6, 2013

Looks good, thanks!

@sjudd sjudd merged commit be3f3ec into bumptech:master Nov 7, 2013
@savvasdalkitsis savvasdalkitsis deleted the shazam_memcache_trim_clear branch November 7, 2013 16:07
@lalith-b
Copy link

how about Runtime.getRuntime.freememory and use a default memory trimmer if freememory is as per the ontrimmeory levels ?

@sjudd
Copy link
Collaborator

sjudd commented Nov 12, 2013

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?

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

Successfully merging this pull request may close these issues.

None yet

4 participants