0

I'm working on a soundboard app, and when I analyze my app, it always detects memory leaks. It works fine on the iOS Simulator, but most sounds do not work on the actual device. I think it has to do with the memory leaks. Any tips. Here is the code. It's only a snippet of all of the code. I am using the AudioToolbox. Sorry, and thanks ahead, I am a very new beginner.

    #import "hilarioussoundboardipViewController.h"

    @implementation hilarioussoundboardipViewController




-(IBAction)sound2 {

CFBundleRef mainBundle = CFBundleGetMainBundle();

CFURLRef soundFileURLRef;

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"sound2", CFSTR ("wav"), NULL);



UInt32 soundID;

AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);

AudioServicesPlaySystemSound(soundID); //it says there is a potential memory leak here//

}
4

2 回答 2

1

您是否曾经调用过“AudioServicesDisposeSystemSoundID”来释放您在代码中创建的 soundID?

于 2011-08-30T00:58:49.343 回答
1

看看Apple 的示例代码。您可能会发现一些有关资源/内存泄漏的提示或有关如何让音频在物理设备上播放的提示。

于 2011-08-30T00:54:58.287 回答