简体   繁体   中英

MPMoviePlayerController using up memory

I have a UIPageViewController as an walkthrough for an app, and I display brief videos of how to use the app.

I have the user press a button when the user is done to go to the main app. However, Xcode in the Debug Navigator shows that the app is still using 53 MB of memory.

Is there a way to deallocate the memory from the movie player? Here is the code that plays the movie.

-(IBAction)playMovie {



mpc = [[MPMoviePlayerController alloc] initWithContentURL:self.imageFiles];
[mpc setMovieSourceType:MPMovieSourceTypeFile];
[[self view] addSubview:mpc.view];
[mpc setFullscreen:NO];

[mpc.view setFrame:CGRectMake(45, 129, 229, 397)];

[mpc play];

}

Here is what I call when the user presses the button to move past the movie-filled intro screens to get to the main app:

- (IBAction)ready:(id)sender {


UIStoryboard *storyBoard;
storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PageContentViewController *pageContentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageContentViewController"];
[pageContentViewController.mpc stop];
pageContentViewController.mpc = nil;
UIViewController *viewController =
[storyBoard instantiateViewControllerWithIdentifier:@"ViewController"];
[self presentViewController:viewController animated:YES completion:nil];


}

So far, the app still has allocated 50 some MB of memory

I think you should assign this MPMoviePlayerController to nil in dealloc function when this view is destroyed OR when you finish this movie:

- (void)dealloc{
  mpc = nil;
}

I think this is not a problem. You can run PROFILE to check memory leak.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM