nek023/QBImagePicker

High memory problems caused flash back in iPad

archerx3 opened this issue · 3 comments

I am using QBImagePicker in my project, I works well and it was very good before.

Preconditions:Just to see the album, not other operations
Recently, the QA test found a high memory problem:

  1. Image count > 1000, running on iPad.
  2. Access camera roll, Fast slide down , caton, than flash back then

I check on code and log, it show me this is not crash and I found received a lot of high memory warning than flash back.

Note:

  1. I had try to set allowsCachingHighQualityImages of PHCachingImageManager to NO, but still received memory warning.
  2. I used demo on iPad, caton phenomenon also occurs.

Now, Can I get some help? Thanks very much.

[self.imageManager requestImageForAsset:asset
                                 targetSize:targetSize
                                contentMode:PHImageContentModeAspectFill
                                    options:nil
                              resultHandler:^(UIImage *result, NSDictionary *info) {
                                  
                                  if (cell.tag == indexPath.item)
                                  {
                                      cell.imageView.image = result;
                                  }
                                  
                              }];
[self.imageManager startCachingImagesForAssets:assetsToStartCaching
                                            targetSize:targetSize
                                           contentMode:PHImageContentModeAspectFill
                                               options:nil];

I found two methods above consume more memory using Instruments.

I fixed this issue with delivery mode option. If you set delivery mode as PHImageRequestOptionsDeliveryModeOpportunistic, memory problem fixes.

Example of code:

PHImageRequestOptions *imageRequestOptions = [PHImageRequestOptions new];
    imageRequestOptions.synchronous = YES;
    imageRequestOptions.networkAccessAllowed = YES;
    imageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic;

[self.imageManager requestImageForAsset:asset
                                 targetSize:targetSize
                                contentMode:PHImageContentModeAspectFill
                                    options: imageRequestOptions
                              resultHandler:^(UIImage *result, NSDictionary *info) {
                                  if (cell.tag == indexPath.item)
                                  {
                                      cell.imageView.image = result;
                                  }
                              }];>

@abdulkerimsahin

Cool!
But the author seems to give up maintaining the warehouse.
This is a pity that the issue of accessing iCloud albums has not been resolved:
Set networkAccessAllowed = YES .