Download GCD receiver warning image

I am developing a photo gallery application using AssetsLibrary to upload photos of my device. When you present a random image in another VC, I noticed the following: an imageView image is loaded for my full image image (the path is much longer than the native photosApp), and I also get memory from the "Received" log after loading several images. If I install my presentation on fullScreenImage, the warnings will stop, but I don’t want it What should I change to ensure smooth performance and high-quality images on the screen?

Here is the code, hope you can tell me what the problem is:

This is VC where I want to present my image on the screen

- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",assetsController); detailImageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; [self.view addSubview:detailImageView]; detailImageView.image = smallImage; //small image is my asset thumbnail and is passed as an argument in my init function dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ALAsset *asset = [assetsController.albumPics objectAtIndex:assetsController.index]; ALAssetRepresentation *representation = [asset defaultRepresentation]; bigImage = [[UIImage imageWithCGImage:[representation fullResolutionImage]]retain]; dispatch_async(dispatch_get_main_queue(), ^{ detailImageView.image = bigImage; }); [pool release]; }); } 

UPDATE 1

  { UIImageView *detailImageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; [self.view addSubview:detailImageView]; detailImageView.image = smallImage; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ALAsset *asset = [assetsController.albumPics objectAtIndex:assetsController.index]; ALAssetRepresentation *representation = [asset defaultRepresentation]; UIImage *bigImage = [UIImage imageWithCGImage:[representation fullResolutionImage]]; dispatch_async(dispatch_get_main_queue(), ^{ detailImageView.image = bigImage; }); [pool release]; }); } 

enter image description here

+2
source share
1 answer

Is bigImage an instance variable? Is it used anywhere except here? If it is not used anywhere, then it should be a local variable, and you should not save it. If this is an instance variable that you save, you need to free the previous value before assigning it a new value.

The same goes for detailImageView

0
source

Source: https://habr.com/ru/post/1208155/


All Articles