hi, it's the first time I use Kingfisher to manage web images. My app crashed down while my tableView scrolled fast, it seems that Kingfisher did not release memory. did I used it wrong?
my code:
imageView.kf_setImageWithURL(NSURL(string: model.thumbUrl)!, placeholderImage: nil, optionsInfo: nil, progressBlock: nil, completionHandler: nil)
my environment: Xcode7.3, swift2.2, iOS8+
The image will be loaded by default if it is started, even you do not use the image after loading finished. You could try to use kf_cancelDownloadTask to cancel a task if you are sure it is no longer needed anymore. See the Cancel Task part of read me for more.
@onevcat 我在UItableviewCell里面用kf加载图片的时候也遇到了相同的问题,搜索了一些答案后发现原因也就快度滚动的时候同时开启了很多加载图片的进程使得内存泄漏,看了你的回复大概明白了解决这个问题的根本是要把一些不在显示范围内的加载进程结束掉,但是现在一直找不到方法处理当快速滚动table时,把已经滚动到主屏幕之外的cell还在没有加载完成的kf加载任务结束掉,不知大神对于这个场景有没有什么办法,还请不吝赐教!
@googlb You could just call kf_cancelDownloadTask in the tableView(_:didEndDisplaying:forRowAt:) method of your table view delegate.
yes, as far as i experimented, KingFisher is not releasing memory cache. (fix me if i'm wrong)
my solution was to fix memory-cache-size in pixels:
KingfisherManager.sharedManager.cache.maxMemoryCost = 600*400*10
Most helpful comment
@googlb You could just call
kf_cancelDownloadTaskin thetableView(_:didEndDisplaying:forRowAt:)method of your table view delegate.