I use kingfisher to load pictures from urls in a tableview. In my controller I have a tableview to display the pictures, a "next" button to reload tableview with new pictures, and a "home" button to go from this view controller to the home view controller.
I use this kind of code to load pictures:
cell.imageInTableCell?.kf.setImage(with: url)
And this to clear my cache when I click on the next button to update the pictures:
ImageCache.default.removeImage(forKey: photoUrl1)
It works fine, I can see ups and downs in my memory use.
My issue is when I try to clear cache when I click on the home button. I used code such as:
ImageCache.default.removeImage(forKey: photoUrl1)
Or:
let cache = KingfisherManager.shared.cache
cache.clearMemoryCache()
cache.clearDiskCache()
cache.cleanExpiredDiskCache()
Or:
ImageCache.default.clearMemoryCache()
ImageCache.default.clearDiskCache()
ImageCache.default.cleanExpiredDiskCache()
It doesn't work, I don't see my memory use decrease. I put these codes in an IBAction with a touchUpInside event, in prepareForSegue and in didReceiveMemoryWarning but nothing happens.
Here is my memory usage when i only use the next button:
And here is my issue with the home button then reload my controller with the pictures then hit the home button again etc :
Do you see what is wrong?
Thank you,