scorpiozj
scorpiozj

Reputation: 2687

memory size of UIImageView

I'd like to know the memory size for a UIImageView object as I need to show some large image and I need to handle the memory. I guess it is decided by the image property. But I'm not sure how to calculate the actuarial memory size,and below is the code I write to test:


    //1.jpg has a size of 4016X2657 and 2.1MB
    NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpg"]];
    NSLog(@"imageData:%d",[imageData length]);

The console shows:


 imageData:2070461

This is exactly the size of 2.1MB.

However, in my opinion the UIImageViewshould know the each pixel to show the image and in other words it should have a memory of : 4016*2657*4/1024/1024 = 40.7+MB It is so large and I don't know whether iOS will do some optimization or not.And I also can't find any relevant in the document.

Could anyone help me what is the exactly memory size of a UIImageView object?

Upvotes: 1

Views: 1004

Answers (1)

scorpiozj
scorpiozj

Reputation: 2687

It is described in the question. The memory is the actuarial size of the photo and UIImage will not do optimization.

Upvotes: 1

Related Questions