ios - 来自 SDWebImage 的 `sd_setImage` 导致的内存泄漏
问题描述
let path = Bundle.main.path(forResource: deviceGuideGif, ofType: "gif")!
let url:URL = URL.init(fileURLWithPath: path)
imageView.sd_setImage(with: url, completed: nil)
我将此代码添加到 viewController(我们称之为 VC1)。当我从其他viewController推送VC1时,内存使用增加了。之后,我弹出VC1并且内存使用没有减少。现在有内存泄漏,我不知道这是怎么发生的。这是错误的使用方式SDWebImage
还是 SDWebImage 中有任何错误?
PS:
如果我使用此代码,它会很好地工作:
let path = Bundle.main.path(forResource: deviceGuideGif, ofType: "gif")!
let url:URL = URL.init(fileURLWithPath: path)
let imageData = try?Data.init(contentsOf: url)
let image = UIImage.sd_image(with: imageData)
imageView.image = image
解决方案
推荐阅读
- python - 可取消后端调用的架构推荐 [zerorpc 如果可能?]
- android - 如何在模块中提供应用程序实例
- amazon-s3 - 尝试使用 AWS Glue 中的笔记本创建动态框架时出现错误“java.io.FileNotFoundException:没有这样的文件或目录”
- sql - 使用管道分隔符在 SQL 查询中将一列拆分为多列
- c# - 用于获取意图的话语列表的 LUIS API 调用失败并出现 404 错误
- airflow - execution_date jinja 解析为字符串
- oracle - PLSQL 函数返回一个 clob,但不清楚它是被隐式释放还是自动释放
- assembly - 为什么这个编码会这样?
- html - 是否可以在角度 HTML 中使用 > 或 < 运算符?
- c - 如何使用批处理文件打开文件,作为批处理文件的输入