What are some of the NSCache's auto-removal policies? Apple's documentation does not mention them, and I experimentally discovered that NSCache does not respond to memory warning.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
NSCache
does not respond toUIApplicationDidReceiveMemoryWarningNotification
, but it does automatically evict its objects in low memory situations, obviously using some other mechanism.While I previously suggested observing
UIApplicationDidReceiveMemoryWarningNotification
, this is not the case. No special handling for low memory situations is needed, asNSCache
handles this automatically.Update:
As of iOS 7, the
NSCache
not only doesn't respond to memory warnings, but it also does not appear to properly purge itself upon memory pressure, either (see NSCache crashing when memory limit is reached (only on iOS 7)).I subclass
NSCache
to observeUIApplicationDidReceiveMemoryWarningNotification
, and purge the cache upon memory warning:You're best off treating
NSCache
as a black box, as much as you can.From Caching and Purgeable Memory (emphasis mine):