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
|
// progressive decode the image in coder queue
|
||||||
dispatch_async(self.coderQueue, ^{
|
dispatch_async(self.coderQueue, ^{
|
||||||
|
@autoreleasepool {
|
||||||
UIImage *image = [self.progressiveCoder incrementallyDecodedImageWithData:imageData finished:finished];
|
UIImage *image = [self.progressiveCoder incrementallyDecodedImageWithData:imageData finished:finished];
|
||||||
if (image) {
|
if (image) {
|
||||||
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
||||||
|
@ -357,6 +358,7 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
|
|
||||||
[self callCompletionBlocksWithImage:image imageData:nil error:nil finished:NO];
|
[self callCompletionBlocksWithImage:image imageData:nil error:nil finished:NO];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +418,7 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
} else {
|
} else {
|
||||||
// decode the image in coder queue
|
// decode the image in coder queue
|
||||||
dispatch_async(self.coderQueue, ^{
|
dispatch_async(self.coderQueue, ^{
|
||||||
|
@autoreleasepool {
|
||||||
UIImage *image = [[SDWebImageCodersManager sharedInstance] decodedImageWithData:imageData];
|
UIImage *image = [[SDWebImageCodersManager sharedInstance] decodedImageWithData:imageData];
|
||||||
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
|
||||||
image = [self scaledImageForKey:key image:image];
|
image = [self scaledImageForKey:key image:image];
|
||||||
|
@ -446,6 +449,7 @@ didReceiveResponse:(NSURLResponse *)response
|
||||||
[self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES];
|
[self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES];
|
||||||
}
|
}
|
||||||
[self done];
|
[self done];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
// Image refresh hit the NSURLCache cache, do not call the completion block
|
// 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:)]) {
|
} 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), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
|
@autoreleasepool {
|
||||||
UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
|
UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
|
||||||
|
|
||||||
if (transformedImage && finished) {
|
if (transformedImage && finished) {
|
||||||
|
@ -258,13 +259,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
[self callCompletionBlockForOperation:strongSubOperation completion:completedBlock image:transformedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
[self callCompletionBlockForOperation:strongSubOperation completion:completedBlock image:transformedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (downloadedImage && finished) {
|
if (downloadedImage && finished) {
|
||||||
if (self.cacheSerializer) {
|
if (self.cacheSerializer) {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
|
@autoreleasepool {
|
||||||
NSData *cacheData = self.cacheSerializer(downloadedImage, downloadedData, url);
|
NSData *cacheData = self.cacheSerializer(downloadedImage, downloadedData, url);
|
||||||
[self.imageCache storeImage:downloadedImage imageData:cacheData forKey:key toDisk:cacheOnDisk completion:nil];
|
[self.imageCache storeImage:downloadedImage imageData:cacheData forKey:key toDisk:cacheOnDisk completion:nil];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
[self.imageCache storeImage:downloadedImage imageData:downloadedData forKey:key toDisk:cacheOnDisk completion:nil];
|
[self.imageCache storeImage:downloadedImage imageData:downloadedData forKey:key toDisk:cacheOnDisk completion:nil];
|
||||||
|
|
Loading…
Reference in New Issue