AutoReleasePool详解

大量生产临时变量,可以使用AutoReleasePool  降低性能的峰值

NSOperation*operation = [NSOperationnew];

dispatch_async(self.ioQueue, ^{

if(operation.isCancelled) {

return;

}

@autoreleasepool{

UIImage*diskImage = [selfdiskImageForKey:key];

if(diskImage &&self.shouldCacheImagesInMemory) {

NSUIntegercost =SDCacheCostForImage(diskImage);

[self.memCachesetObject:diskImageforKey:keycost:cost];

}

dispatch_async(dispatch_get_main_queue(), ^{

doneBlock(diskImage,SDImageCacheTypeDisk);

});

}

});

你可能感兴趣的:(AutoReleasePool详解)