# Emitter Releasing OnDestroy()

**URL:** <https://qa.fmod.com/t/emitter-releasing-ondestroy/23770>\
**Category:** Unity\
**Created:** [December 5, 2025, 12:59pm UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770 "2025-12-05T12:59:45Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonarSoundSB](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@SonarSoundSB](https://qa.fmod.com/u/SonarSoundSB)\
**Post date:** [December 5, 2025, 12:59pm UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/1 "2025-12-05T12:59:45Z")

</div>

Hello,

We’ve had a few problems with memory leaks lately and it seems to be coming from emitters stop trigger…. There are some emitters where we set the stop OnDestroy but they’re not being released properly, I’m debugging like this

```
`protected override void OnDestroy()
{
    if (!isQuitting)
    {
        HandleGameEvent(EmitterGameEvent.ObjectDestroy);

        if (instance.isValid())
        {
            RuntimeManager.DetachInstanceFromGameObject(instance);
            if (eventDescription.isValid() && isOneshot)
            {
                instance.release();
                instance.clearHandle();
            }
        }

        DeregisterActiveEmitter(this);

        if (Preload)
        {
            eventDescription.unloadSampleData();
        }
    }

    if (IsActive) {
        Debug.LogWarning($"IsQuitting: {isQuitting}. Active Emitter: {gameObject.name}. StopTrigger: {EventStopTrigger}.");
    }
}`

```

We’re also not reloading the domain when entering play mode which could be causing instance to stay around too but that doesn’t explain why some emitters which are marked to Stop on destroy aren’t being stopped

Thank you for your time!

---

<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:** [December 8, 2025, 11:11pm UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/2 "2025-12-08T23:11:03Z")

</div>

Hi,

Thank you for bringing this to our attention.

Could I please grab your Unity and FMOD integration versions?

---

<div class="post-metadata">

**Author:** ![SonarSoundSB](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@SonarSoundSB](https://qa.fmod.com/u/SonarSoundSB)\
**Post date:** [December 8, 2025, 11:44pm UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/3 "2025-12-08T23:44:08Z")

</div>

Thanks Connor!

We’re currently using 2.03.10 for both!

---

<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:** [December 10, 2025, 3:40am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/4 "2025-12-10T03:40:02Z")

</div>

Thanks for the info.

Unfortunately, I was not able to reproduce the issue. Would it be possible to create a test Unity project that replicates the issue and upload it to your [profile](https://fmod.com/profile#uploads)?

How are you tracking the memory leaks? Is this happening in builds or in editor?

> [@SonarSoundSB](#):
>
> We’re also not reloading the domain when entering play

---

<div class="post-metadata">

**Author:** ![SonarSoundSB](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@SonarSoundSB](https://qa.fmod.com/u/SonarSoundSB)\
**Post date:** [December 10, 2025, 6:27pm UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/5 "2025-12-10T18:27:08Z")

</div>

Hey Connor,

They’re happening in the editor and after a bit more debugging seem to be related to code trying to access the activeEmitters list after re-entering play mode…. this is happening with looping sources.

I think our understanding was if we mark an emitter to stop OnDestroy then it would be safely released no matter what but this is not happening. So more info, it seems to be happening on 3D events which are not one shots and we have StopEventsOutsideMaxDistance on too, as said before we’re not reloading the domain each time as this slows down dev time.

I’ve uploaded a OnDestroy Test project which should demonstrate what’s going on, if you enter play mode and exit, then re-enter, FMOD throws an error and no sound is played.

Some info on how to safely release emitters would be much appreciated, thanks so much Connor!

---

<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:** [December 15, 2025, 2:43am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/6 "2025-12-15T02:43:16Z")

</div>

Thank you for the project. I have been able to reproduce the issue.

The missing link was the `Reload Domain` as that was allowing the `activeEmitters` list to hand around after relaunching PIE. A work around is removing the `if (!isQuitting)` check from the `OnDestory()` function in the `StudioEventEmitters.cs`. This will result in all Studio emitters stopping when their object is destroyed however. A task to address this issue has been made and will be included in an upcoming release.

Thank you for brining this to our attention.

---

<div class="post-metadata">

**Author:** ![fendercodes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/fendercodes/32/2971_2.png) [@fendercodes](https://qa.fmod.com/u/fendercodes)\
**Post date:** [May 28, 2026, 8:54am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/7 "2026-05-28T08:54:02Z")

</div>

@Connor_FMOD

I’ve seen this issue pop up occasionally even though I am on the latest FMOD versions.

I believe there needs to be a little bit more code in StudioEventEmitter to fully resolve it:

```csharp
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void ResetActiveEmitters()
{
    activeEmitters.Clear();
}

```

and

```csharp
public static void UpdateActiveEmitters()
{
    for (int i = activeEmitters.Count - 1; i >= 0; i--)
    {
        StudioEventEmitter emitter = activeEmitters[i];
        if (!emitter)
        {
            activeEmitters.RemoveAt(i);
            continue;
        }
        emitter.UpdatePlayingStatus();
    }
}

```

---

<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 1, 2026, 1:53am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/8 "2026-06-01T01:53:56Z")

</div>

Thank you for the code.

This issue was addressed in 2.03.13: “Unity - Fixed an issue where active Studio Event Emitters could persist after their owning object was destroyed.” [FMOD Engine | Welcome Revision History](https://fmod.com/docs/2.03/api/welcome-revision-history.html).

Are you following the same reproduction steps as above or are you finding it a different way?

---

<div class="post-metadata">

**Author:** ![fendercodes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/fendercodes/32/2971_2.png) [@fendercodes](https://qa.fmod.com/u/fendercodes)\
**Post date:** [June 1, 2026, 2:18am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/9 "2026-06-01T02:18:52Z")

</div>

Yeah we’re on 2.03.13 and it came up again. But its not consistently happening, at least not from what I can tell. So perhaps a race condition with how things get torn down or with domain reloads in the editor etc.

Regardless, the code suggested is pretty much required I think from looking at StudioEventEmitter. From what I can tell, the `activeEmitters` collection wasn’t being handled correctly in all situations.

I’ve not encountered the errors since making those changes.

---

<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 5, 2026, 4:17am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/10 "2026-06-05T04:17:25Z")

</div>

Thank you for the info.

Unfortunately, I am not able to reproduce the issue testing with reload domain enabled/disabled.

Are you able to share consistent reproduction steps or any logs when experiencing the issue?

---

<div class="post-metadata">

**Author:** ![fendercodes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/fendercodes/32/2971_2.png) [@fendercodes](https://qa.fmod.com/u/fendercodes)\
**Post date:** [June 5, 2026, 5:55am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/11 "2026-06-05T05:55:35Z")

</div>

I’m afraid not. As mentioned, it wasn’t consistent.

What logic had you put into place to handle domain reload issues in the latest patch? Do those attempt to clear `activeEmitters`? As that is what is necessary to do with the attribute:  
`[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]`

---

<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 8, 2026, 5:07am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/12 "2026-06-08T05:07:58Z")

</div>

We moved everything except `HandleGameEvent()` out of the `if (!isQutting)` check to make sure that `DeregisterActiveEmitter()`is called every time the parent object is destroyed.

```csharp
protected override void OnDestroy()
{
    if (!isQuitting)
    {
        HandleGameEvent(EmitterGameEvent.ObjectDestroy);
    }

    if (instance.isValid())
    {
        RuntimeManager.DetachInstanceFromGameObject(instance);
        if (eventDescription.isValid() && isOneshot)
        {
            instance.release();
            instance.clearHandle();
        }
    }

    DeregisterActiveEmitter(this);

    if (Preload)
    {
        eventDescription.unloadSampleData();
    }
}

private static void DeregisterActiveEmitter(StudioEventEmitter emitter)
{
    activeEmitters.Remove(emitter);
}

```

This should be removing all the emitters from the `activeEmitters` list. I could see if the editor is not shutting down correctly this could leave emitters in the list. But I am not sure how to reproduce that.

---

<div class="post-metadata">

**Author:** ![fendercodes](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/fendercodes/32/2971_2.png) [@fendercodes](https://qa.fmod.com/u/fendercodes)\
**Post date:** [June 8, 2026, 5:29am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/13 "2026-06-08T05:29:12Z")

</div>

Hmm, I don’t believe that’s enough when Domain Reload is disabled.

> **[Unity - Manual: Enter Play mode with domain reload disabled](https://docs.unity3d.com/Manual/domain-reloading.html?ampDeviceId=hGxJbJ9GD64K445vuijy0V&ampSessionId=1780885783247&ampTimestamp=1780982839391)**

The attribute mentioned above forces the script to clear the static `activeEmitters` otherwise it can stay populated even when exiting playmode.

---

<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 9, 2026, 5:15am UTC](https://qa.fmod.com/t/emitter-releasing-ondestroy/23770/14 "2026-06-09T05:15:02Z")

</div>

Thank you for the information and the workaround. I have made a task to investigate the issue further.
