- (void)viewDidLoad {
[super viewDidLoad];
landscape.image = [UIImage imageNamed:@"tenerife1.png"];
}
I assign a new UIImage
to the image property of an UIImageView
object. I am not sure if that would result in a memory leak?
- (void)viewDidLoad {
[super viewDidLoad];
landscape.image = [UIImage imageNamed:@"tenerife1.png"];
}
I assign a new UIImage
to the image property of an UIImageView
object. I am not sure if that would result in a memory leak?
No, it should not. The old image should be automatically released when you set the new one, and the "imageNamed" method uses autorelease, so you should be OK there.
Not ordinarily, but it would depend on how you've defined landscape.image. See post above. Be careful with using a lot of these:
Since there is a tendency for these images to fill up memory, without getting released.
It depends on how the
image
property is defined. If it's defined asretain
or, I suppose, evencopy
, it should be fine. You'll end up trying to reference deallocated memory and crashing your program if it's defined asassign
.hey take into account imageNamed has serious memory issues as you loose control over its cache - ie: once you are done with your image, you cannot reclaim that memory. a quick google search would let you know how many people have faced problems with imageNamed
i was at the apple iphone tech talks and the guy giving the presentation confirmed the same damn thing - he suggested using imageWithContentsOfFile instead of imageNamed
if you just have couple of small images, its fine otherwise use imageWithContentsOfFile even though its a bit slower - and implement your own caching logic - check this great link on how to do it here