SDWebImage加载大图片时,内存飙升

简单记录一下问题,主要问题是图片的像素太大了,我们可以手动限制下载的最大像素。

[self.imageView sd_setHighlightedImageWithURL:[NSURL URLWithString:urlStr] 
options:SDWebImageRetryFailed | SDWebImageAllowInvalidSSLCertificates 
context:@{SDWebImageContextImageThumbnailPixelSize : @(CGSizeMake(180, 120))}
 progress:nil 
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        }];

类似上面那样,在context中添加参数 @{SDWebImageContextImageThumbnailPixelSize : @(CGSizeMake(180, 120))}

参考:
内存问题#3034

https://github.com/SDWebImage/SDWebImage/blob/5.8.0/Examples/SDWebImage%20Demo/MasterViewController.m#L121

你可能感兴趣的:(SDWebImage加载大图片时,内存飙升)