4

I recently started working with the AudioToolbox framework and noticed that there is a method called AudioServicesDisposeSystemSoundID().

Just to know, is it a memory leak not to call the above method when calling AudioServicesCreateSystemSoundID() to init my SystemSoundID? I am calling it like:

AudioServicesCreateSystemSoundID((CFURLRef)filePath, &sound);

That way filePath being a NSURL and sound SystemSoundID.

Matoe
  • 2,742
  • 6
  • 33
  • 52

1 Answers1

5

Yes. Call it when you're done with sound. Otherwise, you may leak any memory associated with sound (which can be significant for A/V files.)

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
  • I am actually using it with an AIF file. – Matoe Oct 11 '11 at 15:00
  • A/V = "audio/video". AIF falls under that category. – Jonathan Grynspan Oct 11 '11 at 15:03
  • I got that :p Although I thought you meant 'signigicant for *some* A/V files' – Matoe Oct 11 '11 at 15:06
  • It varies from file to file. That's an implementation detail. Call `AudioServicesDisposeSystemSoundID()` anyway when you no longer need the system sound. – Jonathan Grynspan Oct 11 '11 at 15:07
  • 1
    As described in this question, the sound is not played when AudioServicesDisposeSystemSoundID() is called directly afterwords. Any hints about this? http://stackoverflow.com/questions/29614179/ios-8-audioservicesplaysystemsound-is-not-playing-sound-when-audioservicesdispo – itinance Apr 13 '15 at 20:14