Type Function
Library audio.*
Return value none
Revision Release 2024.3703
Keywords audio, dispose
See also audio.loadSound()


Releases audio memory associated with a handle.


You must not use the handle once the memory is freed. The audio should not be active (playing or paused) on any channel when you try to free it.


audio.dispose( audioHandle )
audioHandle (required)

The handle returned by audio.loadSound() and audio.loadStream() that you want to release.


-- Load a laser sound and a background music stream into memory
local laserSound = audio.loadSound( "laserSound.wav" )
local backgroundMusic = audio.loadStream( "backgroundMusic.m4a" )

-- Play both the sound and the stream
local playLaserSound = laserSound )
local playBackgroundMusic = backgroundMusic )

-- Stop both the sound and the stream and 'nil' out each reference
audio.stop( playLaserSound )
playLaserSound = nil
audio.stop( playBackgroundMusic )
playBackgroundMusic = nil

-- Dispose the handles from memory and 'nil' out each reference
audio.dispose( laserSound )
audio.dispose( backgroundMusic )
laserSound = nil  --prevents the handle from being used again
backgroundMusic = nil  --prevents the handle from being used again