I have created a view in which background is changing randomly.A total of 10 images .that i am using for displaying .
Below is the code for Background images.
- (void)viewWillAppear:(BOOL)animated
{
myTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeImage) userInfo:nil repeats:YES];
}
-(void)changeImage
{
self.imgView.image=nil;
int randNum = rand() % (9 - 1) + 1;.
NSString *num = [NSString stringWithFormat:@"%d", randNum];
self.imgView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",num]];
}
Code is working fine .
My question is;its showing over 34mb memory usage ,when i push other view it's still over 34 mb.although i have make the myTimer
variable nil
;
- (void)viewWillDisappear:(BOOL)animated
{
[myTimer invalidate];
self.imgView.image=nil;
myTimer = Nil;
}
How can i manage memory usage here?