使用requestImageDataForAsset方法显示虚拟内存耗尽

时间:2016-04-06 09:09:55

标签: ios memory photo-gallery

当我使用 requestImageDataForAsset :存储一些数据时,我的相机胶卷中有超过10,000张照片,我已经为 requestImageDataForAsset添加了@ autoreleasepool :但是当我再次运行 requestImageDataForAsset 方法时,app

崩溃 并显示此错误:
错误:libBacktraceRecording.dylib:allocate_free_list_pages() - 虚拟内存耗尽!

for (PHAsset *asset in albumResult){ //there are over 10000 photos

                    if (asset.mediaType == PHAssetMediaTypeImage) {
                        __block NSString *orgFilename = nil;
                      @autoreleasepool {
                        [[PHImageManager defaultManager]
                         requestImageDataForAsset:asset
                         options:imageRequestOptions
                         resultHandler:^(NSData *imageData, NSString *dataUTI,
                                         UIImageOrientation orientation,
                                         NSDictionary *info)
                         {
                             if ([info objectForKey:@"PHImageFileURLKey"]) {
                                 NSString *photoURL = [[info objectForKey:@"PHImageFileURLKey"]absoluteString];
                                 orgFilename = [[photoURL componentsSeparatedByString:@"/"] lastObject];
                    NSArray *keys = [NSArray arrayWithObjects:@"type",@"title",@"status",@"res_resURL",@"path",@"shareName",@"authtok",@"nasIp",@"macAddr",@"albumName",nil];
                    NSArray *values = [NSArray arrayWithObjects:@"assetID",orgFilename,@"queue",asset.localIdentifier,destinationPath,shareName,authToken,nasIp,macAddr,albumName, nil];
                    NSDictionary *dict = [NSDictionary dictionaryWithObjects:values forKeys:keys];
                    [scanedData addObject:dict];
                             }
                         }];
                       }
        }

为什么剂量@autoreleasepool不释放内存? 我检查了xCode调试导航器中的二手内存它总是显示大约130MB,似乎autorelease pool不能完成它的工作?!

0 个答案:

没有答案