Iphone memory management

1.UIImageView * img1 = [[UIImageView alloc] initwithImage: [UIImage imageNamed: @ "1.png"]];

2.UIImageView * img2 = [[UIImageView alloc] initwithImage: [UIImage imageNamed: @ "2.png"]];

a) img1.image = [UIImage imageNamed: @ "2.png"];

b) [img1 setImage:img2];

      

in which direction is the smallest memory used among a and b? why?

if i need to do this multiple times how do you suggest?

-1


a source to share


1 answer


b) Since you are linking to an existing object, but they both point to "2.png". a) you create a new instance of the object, which coincidentally points to the same file, but it is allocated as a separate memory space.



+2


a source







All Articles