It is important to call audio.dispose()
on your loaded audio when you are completely done with the audio file. Doing so allows you to recover the memory.
Releases audio memory associated with the handle.
Syntax:
audio.dispose(audioHandle)
Parameters:
audioHandle
- The handle returned by the audio.loadSound()
or audio.loadStream()
functions that you want to free.
Tip
You must not use the handle once the memory is freed. The audio should not be playing or paused on any channel when you try to free it.
Example:
mySound = audio.loadSound("sound1.wav") myMusic = audio.loadStream("music.mp3") audio.dispose(mySound) audio.dispose(myMusic) mySound = nil myMusic = nil
You have just learned how to dispose audio files properly to recover memory in your application. Try the following:
Load your audio file and have it played over a set duration. Create a function that will dispose of the file when calling an
onComplete
command.In the
Controlling...