Whats up with SetupCoroutine() while Profiling

Hello!

I am currently working on a project with two coroutines running at the same time and the performance is very bad!

With Profiling, I see that “SetupCoroutine()” is growing rapidly with time, also GC work. I attached a screenshot

Does anyone have suggestions what might be the cause? (Either wrong memory management, related to coroutine…)

Further, I would like to use deep profiling, but after playing unity tells me “The profiler has run out of samples for this frame. This frame will be skipped. Increase the sample limit using Profiler.maxNumberOfSamplesPerFrame” although I already set the Numbers of Samples Per frame to 8M

I’m pretty sure there is some kind of bug in the profiler with respect to Coroutines.

This is what I get:

PlayerEndOfFrame 75.9%
  XXX.SetupCoroutine() 75.9%
    Instantiate 23.1%
    Transform.SetParent 3.5%
    CanvasRenderer.OnTransformChanged 0.3%
  YYY.InitData(); 0.0%

In this case, XXX is not active at all during the period when this appears in the profiler, but YYY is. In fact, it is creating thousands of object instances, so it would make sense if that was the source of the spike.

I think that somehow the profiler is getting its measurements mixed up.