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,328 times
0
EmptyStack
- 51,114
- 22
- 146
- 177
Umair_uas
- 675
- 1
- 9
- 26
2 Answers
3
[UIImage imageNamed:] caches the image. Try using [UIImage imageWithData:] instead.
Ruben Marin
- 1,640
- 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
- 19,939
- 11
- 82
- 96
aashi
- 55
- 9