Closed CoderCMY closed 1 year ago
You can limit the memory cache used by Kingfisher following the instructions from Kingfisher Cheat-Sheet:
// Limit memory cache size to 20MB
ImageCache.default.memoryStorage.config.totalCostLimit = 20 * 1024 * 1024
Feel free to feedback if it doesn't work.
You can limit the memory cache used by Kingfisher following the instructions from Kingfisher Cheat-Sheet:
// Limit memory cache size to 20MB ImageCache.default.memoryStorage.config.totalCostLimit = 20 * 1024 * 1024
Feel free to feedback if it doesn't work.
I Just try many times , unfortunately It doesn't work ,My Image Limit Code is Like Below, I Don't Understand what caused the Memory rise too much once using webp format image when use the same configuration,If you find something please tell me.
// 限制Kingfisher的内存和磁盘空间
func configImageLimit(didReceiveMemoryWarning: Bool = false) {
// 允许的内存缓存最大值
var memoryCostLimit: Int = Int(ProcessInfo.processInfo.physicalMemory / 25)
if didReceiveMemoryWarning {
// 收到内存警告时,内存缓存减半
memoryCostLimit = memoryCostLimit / 2
} else {
// 磁盘缓存最大值 150 MB
ImageCache.default.diskStorage.config.sizeLimit = 150 * 1024 * 1024
}
// 内存缓存最大值
ImageCache.default.memoryStorage.config.totalCostLimit = memoryCostLimit
}
```
If your app's memory usage hardly goes far above 200MB, there should not be any issue here because 1/25 of your iPhone 11's physical memory is already 160MB, which you set as the cache limit.
Unlike png images which are decoded using iPhone's hardware, a webp image has to be rendered into a CGContext before being presented on screen, so there should indeed be more memory usage than png ones. It is behaving as intended.
I also noticed that from iOS 14 webp format has a built-in support. We're planning to implement this feature to reduce the memory footprint in iOS 14 devices.
@Yeatse One thing I have observed is that scroll performance takes a major hit with iOS 14 built-in webp support. It seems like Apple is decoding webp to UIImage on the main thread when set on a UIImageView. There are other people who have noticed this as well: https://github.com/SDWebImage/SDWebImage/issues/3132
I noticed some memory leaks in this library when used Instruments
After transfer png to webp format image,Our App memory increase too much like the attachments below,I don't know why and how to fix it,Please give me some advise
e
.