Closed Icemic closed 7 months ago
Hello!
All finished sounds are unloaded whenever you play a new sound - you can see the code that does that here:
Other resources work this way as well.
While removing the lines you mentioned would cause sounds to be unloaded as soon as they finish, it would also mean memory is deallocated on the audio thread, which in rare causes could cause undesirable audio stutters. So this mechanism of sending finished sounds through an SPSC to the gameplay thread to be deallocated later is intentional.
I found that loaded audio resources will not be released after it stops, here is a quick example:
The music will play for 10 seconds and then stop, seeing that no memory usage drop in task manager.
I think it is just because a missing implement of removing it here: https://github.com/tesselode/kira/blob/4c047c3cc60d4f778416e09bc910960d1b482cba/crates/kira/src/manager/backend/resources/sounds.rs#L35-L48
Stopped sound is moved to
unused_sound_producer
but no next steps, while simply comment out line 40~45 will fix the problem.Not sure if the problem exist in other backends or wasm.