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