I’m optimizing GC on a project compiled with Unity 5.3 Win 8 64bit which uses Coroutines like this:
public override void Start() {
StartCoroutine(MyCoroutine());
}
IEnumerator MyCoroutine() {
while (true) {
yield return 0;
}
}
According to the profiler, the example above allocates 37B (shallow profiling) 20B (deep profiling) of memory on every frame:
I couldn’t find much info about this - is it a known issue? Does it happen in production and/or mobile builds? Is it worth avoiding Coroutines when ram or GC spikes are a concern?
And could this be related to the bug in Mono which causes unnecessary boxing when iterating through a List using foreach (as opposed to for int i;;)? I wonder if both are calling MoveNext() at some level.