I ve been doing a project which theoretically should work indefinitely. This means that you started the program, connect Ipad to power supply and it works for days, months, years etc. I was faced with the fact that whatever I do, the memory is gradually allocated, but not released. Instruments Leaks show the absence of memory leaks, but in Instruments Allocations and Activity Monitor memory is gradually allocated, it grows and grows. There are a lot of places where it occurs, particularly when playing videos A simple example (Xcode 4.3, no ARC):
www.un.org/Depts/DGACM/index_french.htm
@interface ViewController : UIViewController
{
MPMoviePlayerController *player;
}
www.un.org/Depts/DGACM/index_french.htm
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
player = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:@"http://mysite.com/movie.mp4"]];
player.view.frame = CGRectMake(400, 500, 360, 240);
[self.view addSubview:player.view];
player.controlStyle = MPMovieControlStyleNone;
player.repeatMode = MPMovieRepeatModeOne;
[player play];
}
- (void)viewDidUnload
{
[player stop];
[player.view removeFromSuperview];
[player release];
[super viewDidUnload];
}
- (void)dealloc
{
[player release];
[super dealloc];
}
This simple application does nothing more, just loop video playback. Every 3 minutes is allocated an average of 100kb. Every day - an average of 40MB. I m profiling with Instruments Activity Monitor. Over time, the app dies. Whats wrong? Why memory is growing, when I just watch video(loop playback) and not initialize new objects?