2011-02-06 31 views
0

AVAudioPlayer對象是否存在內存引導問題?在模擬器中使用AVAudioPlayer時出現內存泄漏。這與我如何創建AVAudioPlayer無關。我用initWithContentsOfURLInitWithData。以下是代碼片段。整個項目@ Github上https://github.com/docchang/MemoryLeakAVAudioPlayerAudioToolbox庫中的內存泄漏AVAudioPlayer

NSError *error; 
NSURL *playerURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Bell" ofType:@"m4a"]]; 
self.playerWithURL = [[AVAudioPlayer alloc] initWithContentsOfURL:playerURL error:&error]; 
if (!playerWithURL) { 
    NSLog(@"no %@.%@: %@",@"Introduction2", @"m4a", [error localizedDescription]); 
} 
playerWithURL.volume = 0.9f; 
playerWithURL.numberOfLoops = 0; 
[playerWithURL play]; 

但是沒有內存泄漏的設備上測試時它。這個問題開始傾向於AudioToolBox庫的問題,但只是想用stackoverflow人來確認它。

回答

0

剛剛進行測試,因爲我遇到了同樣的問題。當使用AVAudioPlayer播放聲音時,樂器在應用程序開始時顯示泄漏。它只在開始時註冊一次。之後產生的聲音沒有任何進一步的泄漏。

當我使用Instruments在iPhone上運行相同的應用程序構建時,根本沒有泄漏。

我運行iOS 11.2.5和Xcode的部署目標是11.0

看起來它只是一個Xcode的錯誤,但可能與M​​acOS的。