I have like 40 sfx files that are getting played back randomly, I load them once and store their references and when I need to playback one of them, I pass it’s file reference to audio.play( handle, options ).
Questions are:
Do I have to nullify the audio handles?
Do I have to do anything to prevent memory leakage in this scenario?
I’ve read posts regarding memory leakage prevention with nullifying audio reference and whatnot but in my case I don’t want to lose references as I need to play them back again and again.
Did you read Rob’s recent tutorial on “modulizing” audio? This may be the solution for you, to allow you to keep your audio loaded in a place where you can manage it easily.
And to answer your first question, audio files/handles must be disposed after you’re done using them (and you don’t need them again). This is explained in some detail in the Audio guide here:
Yes, with audio you must manually dispose of loaded audio files/handles. This is why it’s convenient to localize them to a module or a scene-specific table where you can easily reference them and dispose/nil them when you’re done.
The handles are not allocated memory, it’s a fixed block of lua memory. When you play a 2nd time you write over the original block but it doesn’t use any more memory.
Did you read Rob’s recent tutorial on “modulizing” audio? This may be the solution for you, to allow you to keep your audio loaded in a place where you can manage it easily.
And to answer your first question, audio files/handles must be disposed after you’re done using them (and you don’t need them again). This is explained in some detail in the Audio guide here:
Yes, with audio you must manually dispose of loaded audio files/handles. This is why it’s convenient to localize them to a module or a scene-specific table where you can easily reference them and dispose/nil them when you’re done.
The handles are not allocated memory, it’s a fixed block of lua memory. When you play a 2nd time you write over the original block but it doesn’t use any more memory.