# \[Unity\] Unnecessary RuntimeManager.OnGUI() performance hit?

**URL:** <https://qa.fmod.com/t/unity-unnecessary-runtimemanager-ongui-performance-hit/14637>\
**Category:** Unity\
**Created:** [May 2, 2019, 4:27pm UTC](https://qa.fmod.com/t/unity-unnecessary-runtimemanager-ongui-performance-hit/14637 "2019-05-02T16:27:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjpmetanaut](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@rjpmetanaut](https://qa.fmod.com/u/rjpmetanaut)\
**Post date:** [May 2, 2019, 4:27pm UTC](https://qa.fmod.com/t/unity-unnecessary-runtimemanager-ongui-performance-hit/14637/1 "2019-05-02T16:27:00Z")

</div>

`RuntimeManager` implements the Unity `OnGUI()` method hook to present the FMOD debug overlay. This can be disabled through the plugin settings inspector, but this won’t affect Unity’s registration of the method, which is called as needed by the engine.

I have observed a significant, periodic spike of approximately 4ms in a frame due to GUI garbage collection that appears to be attributed to this method. When removed, the related spikes no longer appear in-editor nor in build.

 ![OnGUI](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/1X/5ef508c2553b07c8c5279b912d0506a1b4c2b438.png)

Has this been observed in other users of the plugin? As in intermittent solution, we have enclosed the method in `#if UNITY_EDITOR`, but would prefer not to modify the plugin source.

* * *

For context, our project is a VR game, with no other `OnGUI()` usage.

The `OnGUI()` implementation can be found in the FMOD codebase here:

> <https://github.com/fmod/UnityIntegration/blob/master/Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs#L411>

---

<div class="post-metadata">

**Author:** ![mythicalcity](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mythicalcity](https://qa.fmod.com/u/mythicalcity)\
**Post date:** [May 2, 2019, 6:18pm UTC](https://qa.fmod.com/t/unity-unnecessary-runtimemanager-ongui-performance-hit/14637/2 "2019-05-02T18:18:20Z")

</div>

Agreed, we ended up commenting this out but should probably not be using onGUI especially for mobile or VR platforms.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 7, 2019, 11:50pm UTC](https://qa.fmod.com/t/unity-unnecessary-runtimemanager-ongui-performance-hit/14637/3 "2019-05-07T23:50:22Z")

</div>

This has been changed in the upcoming release (1.10.13 & 2.00.01) to remove any unnecessary garbage collection when disabled.
