Unity Editor - steady lag increase over time until window is refocused

Unity Version 2019.3.13f1 - Windows 7

In play mode my project is perfectly performant, 60fps.

However, in the editor it slowly starts to lag over time. The fps drops at a steady rate. Strangely, unfocusing then refocusing the Unity Editor resets the lag.

You can see in the editor profiler recording below how Rendering increases steadily over time. Aditionally, there seems to be a steady increase in total memory allocated.

SceneCamera.Finish seems to be what is slowing down over time - selecting anything more under that in the profiler no longer highlights the green “Rendering” area. Unfortunately, there is no information on what SceneCamera.Finish is doing or how to speed it up anywhere online :frowning:

What could possibly be causing this?

Profiler before refocusing Unity Editor:

Screenshot of Profiler before refocusing editor window

Profiler after refocusing Unity Editor:

Screenshot of Profiler after refocusing editor window

OK it took me a while to figure out, but I finally found that I was misusing an asset and causing the lag. (DebugDrawingExtension for those curious - was doing DebugCone instead of DrawCone in OnDrawGizmos).

The way I figured it out was to open up the Gizmos panel, disable all Gizmos, and slowly tick them on one by one as I watched the profiler. When I found which script was causing the graph to rise over time I went in and removed lines one by one from the OnDrawGizmos function and OnValidate function until the lag stopped.

Hope this helps someone!