[UIImage imageWithData:imageData]导致内存暴涨的问题

在app中由于需要获取图片并展示出来,使用了requestImageDataForAsset获取相册照片数据,但是因为用了原图的NSData来实例化了UIImage对象,造成内存猛增,最后替换成requestImageForAsset解决问题。

[[PHImageManager defaultManager] requestImageDataForAsset:imageAsset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
    imageView.image = [UIImage imageWithData:imageData];
}];
- (PHImageRequestID)requestImageForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(nullable PHImageRequestOptions *)options resultHandler:(void (^)(UIImage *__nullable result, NSDictionary *__nullable info))resultHandler;

你可能感兴趣的:([UIImage imageWithData:imageData]导致内存暴涨的问题)