Merge pull request #2475 from zhongwuzw/add_autoreleasepool_to_gcd_block
Add autoreleasepool to release autorelease objects in advance when using GCD for 4.x
This commit is contained in:
commit
88d3e281ca
|
@ -345,6 +345,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
|
||||
// progressive decode the image in coder queue
|
||||
dispatch_async(self.coderQueue, ^{
|
||||
@autoreleasepool {
|
||||
UIImage *image = [self.progressiveCoder incrementallyDecodedImageWithData:imageData finished:finished];
|
||||
if (image) {
|
||||
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
||||
|
@ -357,6 +358,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
|
||||
[self callCompletionBlocksWithImage:image imageData:nil error:nil finished:NO];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -416,6 +418,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
} else {
|
||||
// decode the image in coder queue
|
||||
dispatch_async(self.coderQueue, ^{
|
||||
@autoreleasepool {
|
||||
UIImage *image = [[SDWebImageCodersManager sharedInstance] decodedImageWithData:imageData];
|
||||
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
||||
image = [self scaledImageForKey:key image:image];
|
||||
|
@ -446,6 +449,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
[self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES];
|
||||
}
|
||||
[self done];
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -243,6 +243,7 @@
|
|||
// Image refresh hit the NSURLCache cache, do not call the completion block
|
||||
} else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||
@autoreleasepool {
|
||||
UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
|
||||
|
||||
if (transformedImage && finished) {
|
||||
|
@ -258,13 +259,16 @@
|
|||
}
|
||||
|
||||
[self callCompletionBlockForOperation:strongSubOperation completion:completedBlock image:transformedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (downloadedImage && finished) {
|
||||
if (self.cacheSerializer) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||
@autoreleasepool {
|
||||
NSData *cacheData = self.cacheSerializer(downloadedImage, downloadedData, url);
|
||||
[self.imageCache storeImage:downloadedImage imageData:cacheData forKey:key toDisk:cacheOnDisk completion:nil];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
[self.imageCache storeImage:downloadedImage imageData:downloadedData forKey:key toDisk:cacheOnDisk completion:nil];
|
||||
|
|
Loading…
Reference in New Issue