You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Defaults to 0. Which means there is no memory cost limit.
What happens if the cache continues to grow until the device runs out of memory / disk space? Does SDWebImage alter its caching behavior based on the amount of available memory and disk space? Surely it would be problematic if, over the lifecycle of an app session, the cache consumed more and more memory until there was no memory left for anything else.
What would happen if the device runs out of disk space? Would SDWebImage try to continue caching things and fail, or would it reduce the size of the disk cache?
Currently we are manually checking the amount of disk space and physical memory of the device to set the cache limits, but we want to know what would happen with the default behavior.
Thank you.
The text was updated successfully, but these errors were encountered:
What happens if the cache continues to grow until the device runs out of memory / disk space
NSCache has its own policy to remove some items
Cache objects differ from other mutable collections in a few ways:
The NSCache class incorporates various auto-eviction policies, which ensure that a cache doesn’t use too much of the system’s memory. If memory is needed by other applications, these policies remove some items from the cache, minimizing its memory footprint.
You can add, remove, and query items in the cache from different threads without having to lock the cache yourself.
Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.
And then, iOS system will send UIApplicationDidReceiveMemoryWarning notification.
Does SDWebImage alter its caching behavior based on the amount of available memory and disk space
We currently do nothing. But can do.
The cache impl use NSCache, from Apple...So we can provide a KVO based observation on that NSCache and notify to you (via a callback or notification ?)
Thank you for the info. Is there a recommended practice for setting the maximum cache size for each device, or would it be simplest to set a fixed size that should accommodate effectively all devices and leave it at that? For example, 50 megabytes for memory cache and 100 megabytes for disk cache.
The API headers show that there is no limit for the size of the memory and disk caches by default.
SDWebImage/SDWebImage/Core/SDImageCacheConfig.h
Line 106 in f6afa01
What happens if the cache continues to grow until the device runs out of memory / disk space? Does SDWebImage alter its caching behavior based on the amount of available memory and disk space? Surely it would be problematic if, over the lifecycle of an app session, the cache consumed more and more memory until there was no memory left for anything else.
What would happen if the device runs out of disk space? Would SDWebImage try to continue caching things and fail, or would it reduce the size of the disk cache?
Currently we are manually checking the amount of disk space and physical memory of the device to set the cache limits, but we want to know what would happen with the default behavior.
Thank you.
The text was updated successfully, but these errors were encountered: