I am using HD images and my memory is full after some times, I am update my images with UIImage *image = [UIImage imageNamed:@""];
, is it right in terms of memory?
Asked
Active
Viewed 2,346 times
0

EmptyStack
- 51,274
- 23
- 147
- 178

Umair_uas
- 673
- 1
- 9
- 27
2 Answers
3
[UIImage imageNamed:]
caches the image. Try using [UIImage imageWithData:]
instead.

Ruben Marin
- 1,639
- 14
- 24
-
More info: http://stackoverflow.com/questions/316236/uiimage-imagenamed-vs-uiimage-imagewithdata – Ruben Marin May 04 '11 at 11:56
2
Yes, it is working. In our app we compared with another method like
1)
[self.view setBackgroundColor:[UIColor colorWithPatternImage:
[UIImage imageWithContentsOfFile:[
[NSBundle mainBundle] pathForResource:@"mainScreenBackground" ofType:@"png"]]]];
taken memory usage 22 mb
2)
[self.view setBackgroundColor:[UIColor colorWithPatternImage:
[UIImage imageWithData:
[NSData ] pathForResource:@"mainScreenBackground" ofType:@"png"]]]];
taken memory usage 15mb
thanks alot

Sergey Glotov
- 20,200
- 11
- 84
- 98

aashi
- 55
- 9