I want to clear cache from PHCachingImageManager
as whenever I fetch a new high resolution image, it increases the memory by around 3-4 Mb depending upon the size of the image and eventually crashes the app.
This is the code I'm using for caching the images:
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.synchronous = YES;
options.networkAccessAllowed = YES;
self.cachingManager = [PHCachingImageManager new];
self.cachingManager.allowsCachingHighQualityImages = YES;
[self.cachingManager startCachingImagesForAssets:self.allAssets targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options];
This is how I request for an image:
[self.cachingManager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
imageView.image = result;
}];