# Exponential instance growth/horrible performance in Unity for seemingly no reason?

**URL:** <https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [August 10, 2023, 12:17am UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523 "2023-08-10T00:17:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![themojius](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/themojius/32/5389_2.png) [@themojius](https://qa.fmod.com/u/themojius)\
**Post date:** [August 10, 2023, 12:17am UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/1 "2023-08-10T00:17:27Z")

</div>

From just running the FMOD Engine in my Unity editor for my project, the game runs fine at first, but even without playing a single sound, the number of instances goes up ridiculously high until I literally can’t stop the Unity scene without the entire editor crashing. It goes without saying that the game performance quickly hits hard frame drops.

The number of objects using all of these events total no more than 5-6 GameObjects in the scene. I am using my Master bank in the FMOD Studio project for all of these sound events, and none of them are accessed from an Update() or other per-frame function – they are all situational and context-based, responding to player input or a collision. But even without activating _any_ of those actions, the instance count just skyrockets.

What exactly am I doing wrong here? Attached below is a snippet from the profiler.  
Unity 2022.3.3f1, FMOD Studio 2.02.08.

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

---

<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:** [August 10, 2023, 4:45am UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/2 "2023-08-10T04:45:56Z")

</div>

Hi,

Could you please set the `Logging Level` in the FMOD Settings to `Log`:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/6/64441bdb71a203758965304590d4750f40075a8e.png)  
then share the Editor log after the editor crashes.

In the profiler if you choose the lifespan option: [FMOD Studio | Profiling - Lifespans](https://fmod.com/docs/2.02/studio/profiling.html#:~:text=Lifespans%3A%20Only%20available%20for%20events.%20Displays%20each%20instance%20of%20the%20event%20as%20a%20horizontal%20line.%20Clicking%20on%20one%20of%20these%20lines%20selects%20it%2C%20and%20displays%20the%20parameters%20of%20the%20instance%20in%20the%20deck) which will let you know which event(s) is being initiated exponentially. Please check this event(s) are not being triggered unexpectedly.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![themojius](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/themojius/32/5389_2.png) [@themojius](https://qa.fmod.com/u/themojius)\
**Post date:** [August 11, 2023, 8:52pm UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/3 "2023-08-11T20:52:37Z")

</div>

> then share the Editor log after the editor crashes.

I can’t, because the Unity editor crashes first.

 ![FMOD_Studio_EKtiqOwQHL](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/3678861c68e1c59a603467b2b07af4151546c4d3.png)

Here’s an average profile from that session. At no point am I ever playing more than 7-14 voices, which from my amateur knowledge of sound engines doesn’t exactly constitute “max performance” – but the number of instances just keeps rising. Why is this? I play sounds from events.

And what’s with these weird CPU spikes?

By the way – this is _after_ I’ve limited the Max Instances on sound to 1-4, generally.

Either way, I look forward to you helping me resolve this, and thanks for your help. And the free-to-start software! 😀

---

<div class="post-metadata">

**Author:** ![themojius](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/themojius/32/5389_2.png) [@themojius](https://qa.fmod.com/u/themojius)\
**Post date:** [August 13, 2023, 8:49pm UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/5 "2023-08-13T20:49:26Z")

</div>

I know I’m not entitled to a reply, but I would _really_ appreciate some help here. I’ll write a post if I solve the issue, but this is super frustrating at the moment. Game is unplayable.

---

<div class="post-metadata">

**Author:** ![themojius](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/themojius/32/5389_2.png) [@themojius](https://qa.fmod.com/u/themojius)\
**Post date:** [August 13, 2023, 9:27pm UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/6 "2023-08-13T21:27:00Z")

</div>

Found the solution.  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/23255f267c37f86eecdd1d46a7335dd4b3d85dd7.png)  
This should be self-evident, but don’t create instances _once per frame._

Moved it to `Start()` and everything was alright. Thank goodness.

---

<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:** [August 13, 2023, 10:21pm UTC](https://qa.fmod.com/t/exponential-instance-growth-horrible-performance-in-unity-for-seemingly-no-reason/20523/7 "2023-08-13T22:21:48Z")

</div>

Hi,

Thank you for sharing the solution
