AlamofireImage 没有释放内存
AlamofireImage is not deallacating the memory
我正在将图像从 AlamofireImage 设置为 UITableViewCell
,扩展名为 af_setImageWithURL
当我滚动它太快时它工作得很好,内存大小增加并且 它不会减少但是我停止滚动。
我正在 UITableViewCell
class:
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)
}
内存调试截图如下:
之前:
滚动后:
注意:- 当我在没有图像的情况下滚动时效果很好。
尝试取消分配图像
imgProduct.image = nil
我正在将图像从 AlamofireImage 设置为 UITableViewCell
,扩展名为 af_setImageWithURL
当我滚动它太快时它工作得很好,内存大小增加并且 它不会减少但是我停止滚动。
我正在 UITableViewCell
class:
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)
}
内存调试截图如下:
之前:
滚动后:
注意:- 当我在没有图像的情况下滚动时效果很好。
尝试取消分配图像
imgProduct.image = nil