我用扩展UITableViewCell设置了一个来自AlamofireImage的af_setImageWithURL图像,当我滚动它太快时,内存大小增加了,而没有减少,但是我停止了滚动。
我在UITableViewCell类中使用:
imgProduct.image = UIImage()
clearImageFromCache(imageURL)
let filter = AspectScaledToFillSizeFilter(size: imgProduct.frame.size)
imgProduct.af_setImageWithURL(imageURL, placeholderImage: UIImage(),filter: filter)我也试过NSURLCache.sharedURLCache().removeAllCachedResponses(),但没有运气。
func clearImageFromCache(URL:NSURL) {
let URLRequest = NSURLRequest(URL: URL)
let imageDownloader = UIImageView.af_sharedImageDownloader
// Clear the URLRequest from the in-memory cache
imageDownloader.imageCache?.removeImageForRequest(URLRequest, withAdditionalIdentifier: nil)
// Clear the URLRequest from the on-disk cache
imageDownloader.sessionManager.session.configuration.URLCache?.removeCachedResponseForRequest(URLRequest)
}下面是内存调试的屏幕截图:
以前:

滚动后的:

注意:-当我滚动没有图像时,它工作得很好。
发布于 2017-09-29 12:17:55
试图释放图像
imgProduct.image = nilhttps://stackoverflow.com/questions/46488377
复制相似问题