# Releasing scheduled (setDelay) event instances

**URL:** <https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [June 19, 2025, 8:26pm UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060 "2025-06-19T20:26:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miikakan](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@miikakan](https://qa.fmod.com/u/miikakan)\
**Post date:** [June 19, 2025, 8:26pm UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060/1 "2025-06-19T20:26:41Z")

</div>

Just stumbled upon something interesting while testing our game’s build.  
Audio started stuttering after playing for a while and some events just did not play at all.

I started profiling and I noticed that some event instances that should’ve been released kept stacking up in numbers over time.

The reason for this was that those event instances were “scheduled” using the ChannelGroup.setDelay method. This made is so that just calling `eventInstance.stop(...IMMEDIATE)` and `eventInstance.release()` was not enough. What I had to do was that I had to call `channelGroup.setDelay(0,0,false)` first!

I made this utility method in case it’s helpful for anyone 🙂

```auto
public static void ReleaseScheduledInstance(FMOD.Studio.EventInstance e)
{
    if (!e.isValid()) return;

    if (e.getChannelGroup(out FMOD.ChannelGroup cg) == FMOD.RESULT.OK) cg.setDelay(0, 0, false);

    e.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
    e.release();
}

```

Additionally, I noticed that if you `AddComponent<StudioEventEmitter>()` and don’t set the `emitter.StopEvent` to be anything, they don’t seem to be released correctly either? After setting `emitter.StopEvent = EmitterGameEvent.ObjectDestroy` these “spawned” emitter’s instances did not stack up anymore.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 24, 2025, 5:04am UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060/2 "2025-06-24T05:04:01Z")

</div>

Hi,

Thank you for bringing this to our attention and sharing your workaround.

Unfortunately, I was not able to reproduce the issues in 2.03.

Could I grab some info:

- What version of the FMOD integration are you using?
- Could I grab a code snippet of how you are setting the delay on the events and triggering the event emitter?
- Could I get a screenshot of the events in your FMOD Studio project.

---

<div class="post-metadata">

**Author:** ![miikakan](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@miikakan](https://qa.fmod.com/u/miikakan)\
**Post date:** [July 3, 2025, 7:25pm UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060/3 "2025-07-03T19:25:48Z")

</div>

Hey, the integration version is 2.02.20.

This is the method I mostly use to schedule event instances to play.

```auto
void ScheduleEventInstance(FMOD.Studio.EventInstance eventInstance, ulong startDelay, ulong endDelay, bool stop)
{
    if (eventInstance.getChannelGroup(out FMOD.ChannelGroup cg) == FMOD.RESULT.OK)
    {
        cg.getDSPClock(out ulong d, out ulong pd);

        ulong s = pd + startDelay;
        ulong e = pd + endDelay;

        cg.setDelay(s, e, stop);
        eventInstance.start();
    }
}

```

The instances are created with `FMOD.Studio.EventInstance instance = FMODUnity.RuntimeManager.CreateInstance(eventRef);`. And then released using that method I provided in my initial post.

Here’s a screenshot of an event that is one of the scheduled.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/174c5e5c658c9fab298f3cccd98fb95768afbfc8.png)

---

<div class="post-metadata">

**Author:** ![miikakan](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@miikakan](https://qa.fmod.com/u/miikakan)\
**Post date:** [July 4, 2025, 7:57am UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060/4 "2025-07-04T07:57:58Z")

</div>

Just as an update, after testing a bit more, removing the:  
`if (e.getChannelGroup(out FMOD.ChannelGroup cg) == FMOD.RESULT.OK) cg.setDelay(0, 0, false);`

seemed to work just fine, maybe I was previously releasing them wrong or something but looking at profiler the instance amounts of those scheduled sounds are now dropping to 0 (correctly) when they are released without the setDelay method.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 7, 2025, 2:06am UTC](https://qa.fmod.com/t/releasing-scheduled-setdelay-event-instances/23060/5 "2025-07-07T02:06:42Z")

</div>

Thanks for sharing the info!
