简体   繁体   English

MPMoviePlayerController占用内存

[英]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. 我有一个UIPageViewController作为应用程序的演练,并且显示了有关如何使用该应用程序的简短视频。

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. 但是,“调试导航器”中的Xcode显示该应用程序仍在使用53 MB内存。

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 到目前为止,该应用仍然分配了50 MB的内存

I think you should assign this MPMoviePlayerController to nil in dealloc function when this view is destroyed OR when you finish this movie: 我认为您应该在销毁此视图或完成影片后在dealloc函数中将此MPMoviePlayerController分配为nil:

- (void)dealloc{
  mpc = nil;
}

I think this is not a problem. 我认为这不是问题。 You can run PROFILE to check memory leak. 您可以运行PROFILE来检查内存泄漏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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