Empty more caches — reclaim more memory — on app resigning active.
This commit is contained in:
parent
4ec5990d8b
commit
447aa7a448
|
@ -327,8 +327,17 @@ import Sparkle
|
|||
}
|
||||
|
||||
func applicationDidResignActive(_ notification: Notification) {
|
||||
|
||||
ArticleStringFormatter.emptyCaches()
|
||||
MultilineTextFieldSizer.emptyCache()
|
||||
IconImageCache.shared.emptyCache()
|
||||
accountManager.emptyCaches()
|
||||
|
||||
saveState()
|
||||
|
||||
Task.detached {
|
||||
await DownloadWithCacheManager.shared.cleanupCache()
|
||||
}
|
||||
}
|
||||
|
||||
func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String : Any]) {
|
||||
|
|
|
@ -142,8 +142,7 @@ public final actor DownloadWithCacheManager {
|
|||
public func download(_ url: URL, forceRedownload: Bool = false) async throws -> DownloadData {
|
||||
|
||||
if lastCleanupDate.timeIntervalSinceNow < -DownloadWithCacheManager.cleanupInterval {
|
||||
lastCleanupDate = Date()
|
||||
cache.cleanup(DownloadWithCacheManager.timeToLive)
|
||||
cleanupCache()
|
||||
}
|
||||
|
||||
if !forceRedownload {
|
||||
|
@ -161,4 +160,9 @@ public final actor DownloadWithCacheManager {
|
|||
|
||||
return downloadData
|
||||
}
|
||||
|
||||
public func cleanupCache() {
|
||||
lastCleanupDate = Date()
|
||||
cache.cleanup(DownloadWithCacheManager.timeToLive)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
}
|
||||
|
||||
func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
|
||||
ArticleStringFormatter.emptyCaches()
|
||||
MultilineUILabelSizer.emptyCache()
|
||||
SingleLineUILabelSizer.emptyCache()
|
||||
IconImageCache.shared.emptyCache()
|
||||
accountManager.emptyCaches()
|
||||
|
||||
Task.detached {
|
||||
await DownloadWithCacheManager.shared.cleanupCache()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
|
|
Loading…
Reference in New Issue