ImageView retained by kingfisher when it should be dealloc
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
- [ ] I have read the wiki page and cheat sheet, but there is no information I need.
- [x] I have searched in existing issues, but did not find a same one.
- [ ] I want to report a problem instead of asking a question. It'd better to use kingfisher tag in Stack Overflow to ask a question.
Issue Description
What
when vc poped, imageview should dealloc, but it not happend when loading image use kingfisher. and it real deinit after load remote image finish.
kingfier retain imageview by self.base
Reproduce
[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]
Other Comment
[Add anything else here]
As the KingfisherWrapper itself is a struct (which contains the actual image view as a reference), it would be quite difficult to prevent the holding in the closure. If the extended lifetime is not desired, you can try to call cancelDownloadTask on the imageView.kf to terminate the processing:
class MyViewController: UIViewController {
deinit {
imageView.kf.cancelDownloadTask()
}
}
wow, it used in many places. This approach doesn't seem to work. Will there be no optimization for this area in the future?
@bing-feng-v587 When you write, ‘This approach doesn’t seem to work,’ do you mean that the proposed solution isn’t fixing the problem, or is it not acceptable for your project because there are many parts of your codebase that would need to be adapted?
yes, there are many parts in my code that need to be adapted