Memory Leak still persists in 2.02

Hi.

I am using FMOD 2.02 and Unity 2020

EventInstance.release() is not working. MEMORY: cur just keeps building up and never goes down throughout the runtime of the app… and max keeps going up and doesn’t go down ever.

I use the scripting reference from here: https://www.fmod.com/resources/documentation-unity?version=2.02&page=examples-basic.html

… Doing exactly what it says.

In FMOD my event is set to “steal oldest”

I updated to the newest version of FMOD (and Unity FMOD integration) because another thread here said that was the problem, but the problem remains.

image

I am assuming that the unity object doesn’t have to be disabled for .release() to work?

image

I suppose I could build an object pooler in Unity, but I’d rather want FMod API to work as stated, if at all possible.

It seems the events never reach the playback state “STOPPED” … Could that be the problem?

What could be the reason the event never gets to state “STOPPED” ?

Now I notice that when I play the sample in FMOD Studio the playback goes from “PLAYING” to “STOPPING” but never reaches “STOPPED” … I was under the impression that it would go to stopping automatically as the sample finishes?

Do I need to set some stop flag in FMOD Studio? Where do I do that?

image

Update:

No, the memory leak persists for another event that does stop after playing (set up differently than the one in the pic above) … even though I call .release() on the instance after it is started the memory usage goes up and up… so it seems the events are never destroyed/disabled/ etc. After about ten minutes of playing on mobile the sound starts cracking because of memory overload.

Can somebody please help me, or is this forum not active?

Do you have an AHDSR modulator with a long release on the master fader? That’s the only way I would think the Event would stay on “Stopping”. At least I can see there is something still acting on the master fader in your screenshot. You could call Studio::EventInstance::stop with FMOD_STUDIO_STOP_IMMEDIATE before releasing if you want the event instance to stop immediately without waiting for AHDSR modulators.

Releasing an event only occurs once an event instance has come to a complete stop. If you are not calling an immediate stop on an event, instead allowing for fade out, then it will wait until the event instance has finished the “STOPPING” playback state and entered the “STOPPED” playback state.

There is something that is preventing your event from stopping properly. Check for the following:

  • Make sure the event macro is not set to Persistent
  • Make sure there are no loop regions, transition regions, or sustain points in the event

If possible, please show a screenshot of the entire event for us to look at if you are still having issues.

Thanks for the replies, guys.

This is the whole screen shot of the event that doesn’t stop, but that doesn’t seem to be the problem though as I have looked further into it… Even if I use another event that does stop as soon as the sample is over (The Bell event), the FMOD memory debug display in Unity just goes up and up and never goes down. … Play the game (in an android build) for about 10 minutes (only using the Bell event) and the sound starts crackling.

I am using ADSHR on some events, including the bell that stops fine (but still causes a memory leak in Unity), but not the other one, BassDrone, (which also causes a memory leak but doesn’t stop).

‘Persistent’ isn’t on, and there are no loop regions, transition regions, or sustain points in the event

image

It sounds like there is definitely something in your event that is preventing you from stopping with fade out. Are you able to copy this event to a new project and to send it over to look at? You can send it over to support@fmod.com or DM me.

Thanks for sending through the project.

It turns out that the Oculus Spatial Reverb is not going idle. So whilst the event is “stopped” and no audio is playing, the Oculus Spatial Reverb effect is keeping the event alive in the “stopping” state. It is odd that this happens with some events but not others, but it is definitely the reverb effect that is causing this. You will need to bring this up with the Oculus developers to fix in a future update.

There is a workaround which is to move the Oculus Spatial Reverb effect to a return bus and use a send effect. This will allow the event to stop naturally and the reverb to play out.

Ahh… Thanks so much.

I see now in the Oculus Fmod Instructions that they assume you will put the Oculus Spatial Reverb on the master track and not each event.

can’t remember why I thought I needed to put it on each event, been a while since I was working in the fmod project.

Seems to work now (i.e. with Oculus Spatial Reverb on the Mixer → Master Return track, and then Oculus Spatializer on each event)

Thanks a bunch, and happy new year :slight_smile: