English 中文(简体)
MPMoviePlayerController仍然泄露
原标题:MPMoviePlayerController still leaking

I release the MPMoviePlayerController but the memory allocation and the living objects are still higher than before the object allocation. However if I reallocate the object it doesn t leak more. My application actually uses a lot of media files and the memory consumption is high. I would like to free up completely the unneeded memory to avoid memory warnings.

电影发行人:

        player.initialPlaybackTime = -1;
        [player.view removeFromSuperview];
        [player stop];
        [player release];

电影演员:

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video0_hd.mov" ofType:nil]];
    player = [[MPMoviePlayerController alloc] initWithContentURL:url];
    player.view.frame = placeholder.frame;
    [self.view addSubview:player.view];
    [player play];
最佳回答

我也有这个问题。

The cache used by the iPad for preloading the video stream, was not emptied completely. So each time, this page with the video player was cleaned up and released, the allocated memory after cleanup still contained the cached memory. For big video s, this could be up to 50 MB.

这实际上不是记忆泄露:

如果该网页再次开通,海滩就重新定位。 但是,由于你想要一个干净的退学状况,即当这一页被留下并清理时,这一页所用的一切记忆都应放开,包括用于拍摄录像流的记忆。

在经过一段严肃的每周工作之后,这一指挥顺序似乎做了以下工作:

=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:myMoviePlayer];        

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerDidExitFullscreenNotification
                                                  object:myMoviePlayer];        

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerLoadStateDidChangeNotification
                                                  object:myMoviePlayer];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMovieDurationAvailableNotification
                                                  object:myMoviePlayer];        
    [myMoviePlayer pause];
    myMoviePlayer.initialPlaybackTime = -1;
    [myMoviePlayer stop];
    myMoviePlayer.initialPlaybackTime = -1;
    [myMoviePlayer.view removeFromSuperview];
    [myMoviePlayer release];

===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

步骤:

页: 1

2 - 电影

3 - 设定启动游击时间

4 - 停止电影

5 - 再次启动游乐

6 - 现在删除电影观点

7 - 最后释放电影演员

Resulting in my case in also the video cache memory being released on my iPad (OS 4.2.) and leaving a clean allocated memory situation, equal to the size before the page with the video player was openen. So same enter and exit memory.

希望......

问题回答

您是否尝试了建设和分析(Build>Build和Analyze),这可以显示你准确的直线记忆(如果有的话)。

现在我感觉到问题在于你界定了

你们是否在装置上或模拟器上操作该守则? 模拟器提供一股虚假的泄露(例如音像资料箱、核心数据集等)。 此外,模拟器似乎在entire上 c。 录像,而不是适当释放,而装置只缓冲其需要。

我在模拟器上测试了带有4摄像机的密码,我取得了与你所说的类似结果(每当录像时,有10个活物体,没有死亡......20mb被分配,5mb甚至在释放后就离开)。 活物体和记忆分配将不断增长,并不断发展。

然而,在我的台(有20米布录像)上,它只分配了900kb的记忆,用于照相,在录像开始/播放/播放时没有明显的变化。 在我测试的10次时间里,它一直停留在900kb左右(启动/停用/更换)。

就像你能够信任模拟者的另一个时候。

第一版正在测试:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"SomeMovieFile" ofType:@"mp4"]];

MPMoviePlayerController *newPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

self.player = newPlayer;  
[newPlayer release];

[self.view addSubview:player.view];  // for my example, I didn t set the frame location, but no difference that would do
[player play];

随后,在另一个纽顿,我停下来,释放了参与者:

[player.view removeFromSuperview];    
player.initialPlaybackTime = -1;
[player stop];
self.player = nil;  // this is just a habit of mine.. calling stop should unload the buffers though
[player release];




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签