3

AVAudioPlayer オブジェクトにメモリ リードの問題はありますか? シミュレーターで AVAudioPlayer を使用すると、メモリ リークが発生します。AVAudioPlayer をどのように作成したかは関係ありません。と を使用initWithContentsOfURLしましInitWithDataた。以下はコードのスニペットです。完全なプロジェクト @ Github https://github.com/docchang/MemoryLeakAVAudioPlayer

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 関係者に確認したいだけです。

4

2 に答える 2

5

AVAudioPlayer を使用すると、同じメモリ リークが発生します。Web 上の AVAudioPlayer および VideoPlayer ライブラリで同様のリークが発生したという投稿をいくつか見ました。ライブラリ自体に問題があるようです (Apple のせいです):

  1. iPhone: OpenAL と AudioToolbox のリーク
  2. https://appcelerator.lighthouseapp.com/projects/32238/tickets/1992-ios-strange-behavior-and-intermittant-mem-leak-on-embedded-video-test-case

編集:ターゲットがデバイスで実行されると、リークが消えるのも見られます。

于 2011-02-24T09:26:17.647 に答える