-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Feature] add auto purge on memory event #1141
[Feature] add auto purge on memory event #1141
Conversation
I like this, but do we want to remove ALL objects? Is there a way to remote just everything but the most recently cached n objects? |
@markrickert yeah that would be ideal, but from what i can tell For over a year I have been fighting a bug where a long session would run up the memory and crash/shutdown when a memory intensive action followed. I was always under the assumption that this was perfectly normal to run up this cache as the system would reclaim it when needed, i figured it was just some memory leak inside other libraries like I hate this PR, but short of completely turning off NSCache as #1130 or rewriting a real LRU eviction policy, we are being terrible netizens at the moment. A good start might be to leave a message in the README about carefully configuring SDWebImage on the context of the app and to carefully monitor memory so that maximum cost and count limit are set correctly |
@@ -48,6 +48,11 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot | |||
@property (assign, nonatomic) NSUInteger maxMemoryCost; | |||
|
|||
/** | |||
* The maximum number of objects the cache should hold. | |||
*/ | |||
@property (assign, nonatomic) NSUInteger maxMemoryCountLimit; |
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.
This was part of another PR right?
I agree, the right fix is to implement an LRU cache. I don't have the bandwidth to do that right know, but if someone want to send a PR, I have the feeling that a lot of people would be grateful. In the meantime I'm gonna accept this PR as it is a good meantime tradeoff. Could you please remove the part of the PR that belongs to anothers? |
closing for #1143 |
This will probably be more controversial (it shouldn't be though) so i separated it from #1140
Inspired from
http://stackoverflow.com/a/19549090/775762
related to #538