Kingfisher: memory warning & app crashed!

Created on 3 May 2016  ·  4Comments  ·  Source: onevcat/Kingfisher

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+

Most helpful comment

@googlb You could just call kf_cancelDownloadTask in the tableView(_:didEndDisplaying:forRowAt:) method of your table view delegate.

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joebenton picture joebenton  ·  4Comments

HuseyinVural picture HuseyinVural  ·  4Comments

jacowu picture jacowu  ·  4Comments

indrajitsinh picture indrajitsinh  ·  5Comments

SURYAKANTSHARMA picture SURYAKANTSHARMA  ·  4Comments