【发布时间】:2011-04-01 10:14:29
【问题描述】:
在释放 MPMoviePlayerController 对象后,我在 iPad 应用上遇到了 CoreVideo 完成的 3MB malloc。
我已确保播放器在释放之前停止,因此它确实确实释放了内存并正确释放。问题是仪器一直显示这个尚未发布的malloc(并且我没有在我的代码中直接使用) 这是在仪器中显示为从未发布的 3.52MB Malloc 的负责调用者的调用。
CVPixelBufferBacking::initWithPixelBufferDescription
这是停止播放器并释放包含它们的数组的代码
- (void)dealloc {
...
[self stopAllPlayers];
[_moviePlayerViewControllerArray release];
[super dealloc];
}
-(void)stopAllPlayers {
for (MPMoviePlayerController *mp in _moviePlayerViewControllerArray) {
[mp stop];
}
}
这是添加视频的方法
-(void)addVideo:(NSString*) videoName onRect:(CGRect)rect {
......
MPMoviePlayerController * movieController= [[MPMoviePlayerController alloc]initWithContentURL:(NSURL *)videoURL];
// set frame for player
movieController.view.frame = rect;
// set auto resizing masks
[movieController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
// don't auto play.
[movieController setShouldAutoplay:NO];
[pdfView addSubview:movieController.view];
[pdfView bringSubviewToFront: movieController.view];
[_moviePlayerViewControllerArray addObject:movieController];
[movieController release];
}
编辑:添加图像。美丽的 3MB malloc 尽显荣耀。
如您所见,另一块内存不再存在,但我仍然有一个大问题。 提前感谢您的帮助
【问题讨论】:
-
请用您的代码 sn-p 和仪器屏幕截图更新您的问题,也许我可以帮助您。
-
嘿,我刚刚添加了sn-ps和截图! :-)
-
你是在设备上还是在模拟器上测试过?我认为电影控制器的情况存在一些差异。
-
确实你是对的。我现在有一大块 8MB 的 CoreGraphics,负责的调用者是 CGDataProviderCreateWithFileName
标签: iphone objective-c memory-management memory-leaks instruments