-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
加载大图内存暴增,memory一直增加 #2322
Comments
咱们可以处理一些么 减缓 加载大尺寸图片 内存过高这个问题,我这详情还是要加载原尺寸图片的呢 |
@make1a 确实这个方式可以缓解 session 那边的压力。但直接使用 所以可能需要思考一下怎么才能比较优雅地处理。也许可以用一个 provider 来解决..我试试看。 |
I tried to implement a provider based solution with the URL image source. It is now in this branch ( Some code snippet to use it: let p = ThumbnailImageDataProvider(url: url, maxPixelSize: 100)
imageView.kf.setImage(with: .provider(p)) |
@objc
/// 加载本地的图片
/// - Parameter path: 本地路径
public func oc_kfSetImage(path: String?, placeholderImage: UIImage?, size: CGSize, complete: ((UIImage?) -> Void)?) {
guard let path = path else { return }
let url = URL(fileURLWithPath: path)
let provider = LocalFileImageDataProvider(fileURL: url)
var options: KingfisherOptionsInfo = [
.scaleFactor(UIScreen.main.scale),
.cacheOriginalImage
]
// 获取合适大小的图片展示
if !url.absoluteString.contains("gif"), size != CGSize.zero {
options += [.processor(DownsamplingImageProcessor(size: size))]
}
kf.setImage(with: provider, placeholder: placeholderImage, options: options){ result in
switch result {
case .success(let value):
complete?(value.image)
case .failure(_):
complete?(nil)
}
}
} @onevcat In this situation, it seems that the |
@onevcat I encountered a problem as well, the webp images cannot be displayed, and the system provided the following error log:
|
@onevcat I think I have a similar issue here I'm not sure if its a memory leak though. I have a social media app and the memory cache is getting too large. I have multiple scrollviews with KFimage and I am downsampling the image as well
The image downsamplingprocessor seems to make the memory go down a bit but it will continue to go higher and higher the more images I load even if I delay it with the downsamplingimageprocessor.
and none of this actually stops the amount of data in the cache it will go to around 3gb and crash also just like in this post |
加载尺寸大的图片内存会一直增
"https://file.guangshaxx.com/detail/2f20eae35be594a963624b7849b8e8eb.jpeg";
图片1.7m,4608 × 3456
用collectionview 复用 30多个cell 加载真机上会超过1gb然后,内存警告 crash,
尝试用
self.kf.setImage(with: url,
placeholder: placeholderImage,
options: options ?? [
.transition(.fade(0.2)),
.cacheOriginalImage,
.processor(DownsamplingImageProcessor(size: CGSize(width: 336, height: 300)))
])
.processor(DownsamplingImageProcessor(size: CGSize(width: 336, height: 300)))
可以降低内存 ,但是memory还是一直增加
设置
// 配置缓存的大小
let memoryCacheSize: Int = 50 * 1024 * 1024 // 50 MB
let diskCacheSize: UInt = 200 * 1024 * 1024 // 200 MB
无效~
手动清理
ImageCache.default.clearMemoryCache()
也无效
The text was updated successfully, but these errors were encountered: