Size limit in UIImageView?

ios, objective-c, uiimage, uiimageview

Solution

Your image just crashed the Chrome tab I tried to display it in on a 4GB laptop. It also caused my laptop to sputter quite a bit before it was saved.

It is a 36MB jpeg compressed bitmap. 18K x 18K pixels. Let's do some math.

Given the resolution, you have 324000000 pixels in all. 324M pixels. Each represented by 3 bytes of color info in memory. A good approximation would be 1GB of raw pixel data in all then. And I am not sure that takes into account how a `UIImage` instance stores that internally.

Given the above and the fact that the most recent (and powerful) iOS devices have 1GB of RAM in total, I think it would be safe to say that the image is too big even if there is not inherent size limit invovled.

Problem

I'm trying to display a rather big image in a `UIImageView`. The image downloads correctly (using a `NSSessionDownloadTask`) and I can create a `UIImage` from it, however, nothing is displayed in the UIImageView. I don't get any memory warnings or errors. Anybody knows what's going on? ``` -(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location { UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:location]]; self.imageView.image = image; self.progressView.progress = 0.0f; [self.activityView stopAnimating]; [self.activityView setHidden:YES]; NSLog(@"Received full Image!"]; } ```

Original source