开发者

Xcode Audio Memory Leak?

开发者 https://www.devze.com 2023-04-01 17:25 出处:网络
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

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 hilarioussoundboar开发者_开发技巧dipViewController




-(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//

}


Take a look at the example code from Apple. You might find some hints about resource/memory leaks or hints about how to get audio to play on the physical device.


Have you ever called "AudioServicesDisposeSystemSoundID" to free the soundID you've created in your code?

0

精彩评论

暂无评论...
验证码 换一张
取 消