使用AVAudioPlayer进行内存泄漏

Luc*_*lon 1 cocoa memory-leaks objective-c avaudioplayer ios4

我正在使用检测分析Objective-C++代码中的泄漏,我得到了这个:

Leaked Object   Address Size    Responsible Library Responsible Frame
Malloc 32 Bytes,0x8135bc0   32 Bytes    AudioToolbox    SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
__NSCFDictionary,0x8135be0  48 Bytes    AudioToolbox    CreateDictionaryForDevice(unsigned long)
Malloc 32 Bytes,0x8135c10   32 Bytes    AudioToolbox    CreateDictionaryForDevice(unsigned long)
Malloc 32 Bytes,0x8135c30   32 Bytes    AudioToolbox    CreateDictionaryForDevice(unsigned long)
Malloc 48 Bytes,0x8135c50   48 Bytes    AudioToolbox    SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
__NSCFDictionary,0x813a820  48 Bytes    AudioToolbox    SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
__NSCFArray,0x813a850   32 Bytes    AudioToolbox    SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
__NSCFDictionary,0x813a870  48 Bytes    AudioToolbox    CreateDictionaryForDevice(unsigned long)
Malloc 32 Bytes,0x813a8a0   32 Bytes    AudioToolbox    SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
Malloc 32 Bytes,0x813a8d0   32 Bytes    AudioToolbox    CreateDictionaryForDevice(unsigned long)
Run Code Online (Sandbox Code Playgroud)

我认为这与我编写的代码有关,当我的应用程序启动时播放声音.我是这样做的:在applicationDidFinishLaunching ::中调用此方法

- (void)playJingle {
    // This is a detached thread so I need a new pool.
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

    // This audio player will be released in  audioPlayerDidFinishPlaying.
    NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:@"jingle" ofType:@"m4a"];
    AVAudioPlayer *av = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL];
    [av setDelegate:self];
    [av play];

    // Release.
    [pool release];
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)av successfully:(BOOL)flag
{
    // Release the AVAudioPlayer.
    [av release];
}
Run Code Online (Sandbox Code Playgroud)

在后台线程中(使用performSelectorInBackground:withObject :)调用.我错过了什么吗?为什么我会有这些泄漏?谢谢!

mmc*_*omb 6

您是否尝试在设备上运行该应用程序?AVAudioPlayer在模拟器上容易出现误报和内存泄漏检测...

这是一个非常相似的问题,具有类似的泄漏报告