My program has a memory leak

前端 未结 5 1934
孤独总比滥情好
孤独总比滥情好 2021-01-16 22:17
-(IBAction)play2;

{
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef =CFBundleCopyResourceURL(mainBundle, 
           


        
5条回答
  •  终归单人心
    2021-01-16 23:00

    CFBundleCopyResourceURL contains copy so your retain count on soundFileURLRef is in fact 1. When you are done with it call CFRelease(soundFileURLRef) to decrement your retain count.

    In addition to the error you're getting, SAKrisT's answer about calling AudioServicesDisposeSystemSoundID on the object you created with AudioServicesCreateSystemSoundID is also something to address.

提交回复
热议问题