0

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?

EmptyStack
  • 51,114
  • 22
  • 146
  • 177
Umair_uas
  • 675
  • 1
  • 9
  • 26

2 Answers2

3

[UIImage imageNamed:] caches the image. Try using [UIImage imageWithData:] instead.

Ruben Marin
  • 1,640
  • 14
  • 24
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