【发布时间】:2011-03-27 03:49:29
【问题描述】:
我在 iPhone SDK 中的新 AVFoundation 类中遇到了一种奇怪的行为。
我有一个用于拍照的 AVCaptureStillImageOutput,我正在根据自己的喜好设置它的 outputSettings。代码如下:
AVCaptureStillImageOutput *stillImageOutput = [[[AVCaptureStillImageOutput alloc] init] autorelease];
[stillImageOutput setOutputSettings:[NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey]];
[self setStillImageOutput:stillImageOutput];
(stillImageOutput 属性定义为“保留”)
我偶然发现了泄漏中的泄漏,setOutputSettings 行有 100% 的泄漏故障。我相信我仅限于附加代码中的内存管理指南,但它仍然在泄漏。
我的解决办法是
[self.stillImageOutput setOutputSettings:nil];
在dealloc中,就在
之前[self setStillImageOutput:nil];
泄漏确实停止了,但看起来很奇怪。 stillImageOutput 的释放不应该也释放它的 outputSettings 属性吗?
无论如何,如果其他人遇到这种情况,我想我应该分享我的解决方案。
干杯!
奥德。
【问题讨论】:
标签: iphone memory sdk memory-leaks avfoundation