- Home /
How to debug unity editor performance?
I am well aware that running a game inside the editor is worse on performance than if I built a stand alone build, but of course some times it is impractical to build every time I need to run the game. However, lately I have been having an issue in my project where every time I hit play, editor performance gets worse. There are spikes every X seconds, the first time I play, they last 0.1s, then after running the game in editor 3-5 times they get up to .25, then .5, then 1, etc and keep getting worse. I can tell that the issue is in editor because the profiler clearly shows the spikes in the editor segment. The issue also doesn't occur in stand alone builds.
I assume it is an issue of some static value in my game or editor scripts that isn't getting cleared in between play sessions in editor, but since the editor segment in the profiler doesn't give me a breakdown like the rest of the game, I am having a really hard time tracking down where the issue is occurring.
Does anyone have any tricks or suggestion for debugging untiy editor performance?
Answer by Bunny83 · Sep 27, 2021 at 06:55 PM
There are no static values what are not cleared up. Whenever Unity compiles your scripts everything is completely destroyed. The whole managed Mono environment will be taken down and restarted. Are you sure you don't have anything related to threads that you don't end gracefully? Threads are usually the only things that may cause issues when not properly ended.
Though we don't know anything about your project, so it's difficult to say anything about it. Have you actually run a deep profile?
That is excellent information! I am running threads. And I am just inexperienced enough with them to very likely have bugs ending them gracefully. That gives me a place to look at least.
fwiw I was running with deep profile on, but it doesn't' expose anything on the editor side. I'm not on Unity Pro. If I recall correctly Pro comes with the unity source code, so maybe if I were running pro I could profile editor as well as my game code? ¯_(ツ)_/¯
Ah... derp. There is literally a box at the top of the profiler to "Profile Editor" I somehow never noticed that. So yeah. I can totally profile editor after all...