Coroutine: MoveNext Causing Stutters

Hello,

I am trying to debug performance issues and have noticed these spikes in the profiler. These seem to be happening whenever new seekers are being instantiated on the scene, given a set of waypoints to follow and started to move. I am using a 1000x1000 layered grid graph with node size of 1, which I am theorizing is related.

The TimeManager.UpdateGameTime call you see in the screenshot, is an event that triggers the seeker to be instantiated, and set on its way.

Image_23

Please note that I still have the optimization settings you recommended here, turned on. Any ideas what may be causing this?

Hi

That looks like it is purely the garbage collector that is causing the spikes.
The size of those spikes will be roughly proportional to the amount of memory that your whole game has allocated, and the frequency will depend on how much memory you allocate per frame.

You’ll probably want to look into object pooling.
Might help to use a recent version of Unity with the .net 4 runtime as well (though make sure to profile).