Garbage Collection (StackTraceUtility) - Profiler Spikes

Hello everyone.

Whenever I profile my game I keep getting Garbage spikes. I checked and the most Garbage comes from something called ‘StackTraceUtility’. And I also get huge random spikes from ‘Others’. Is it also part of Garbage Collection?

I checked about this on the internet, but haven’t found much useful information. Can someone please give some tips on how can I fix / avoid this annoying issue? Thank you!


After Deep Profile:

Do you have any Debug.Logs somewhere in your code which are executed every frame? Debug.Log has a huge hit on performance, especially inside the Editor. Each log has a full stacktrace which can be viewed in the console. Avoid using Debug.Log every frame. This should only be done temporarily for debugging purposes and removed immediately after.

You may have other things in your code which is generating garbage. You can switch the profiler into “deep profiling mode”. This mode has a much larger impact on the performance in the editor, but it tells you exactly which method is being executed how many times a frame and how much memory got allocated by each method. This should help to track down what is generating garbage.