tags:

views:

46

answers:

2

How much memory alloc an UIImageView 320x480?

+1  A: 

A bunch? There are helper objects, properties which point to other objects, etc. Trying to track down everything that might happen is probably not worth it. Why do you need to know?

Check out this question which has some good informattion about the runtime.

Carl Norum
`sizeof` is not useful at all for determining the memory use of Objective-C classes.
rpetrich
@rpetrich, that's kind of what I was trying to get at; edited for better information.
Carl Norum
+1  A: 

Normally a 320x480 UIView would consume an additional 320*480*4 bytes for the layer's buffer, but in OS 3.0 UIImageView was optimized to use the source UIImage directly.

It has only a small overhead necessary to maintain the high-level UIView interface. To reduce this even further, you can create a CALayer and assign the contents directly:

CALayer *layer = [CALayer layer];
[layer setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
[layer setContents:(id)[image CGImage]];
[[superview layer] addSublayer:layer];
rpetrich