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,274
  • 23
  • 147
  • 178
Umair_uas
  • 673
  • 1
  • 9
  • 27

2 Answers2

3

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

Ruben Marin
  • 1,639
  • 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
  • 20,200
  • 11
  • 84
  • 98
aashi
  • 55
  • 9