When using generator co-routines (functions with many yield return
s), no array is created or allocated. Everything is done in a streaming fashion. It is entirely possible to have infinite generators that work without getting an out of memory error:
public static IEnumerable<int> Odds(){
for (int i = 1 ; ; i += 2)
yield return i;
}
Therefore, if you frequently return big arrays only to be iterated and disposed immediately, the benefits will be huge, as the memory allocations will be much smaller. The garbage collector will be called less often and will have less work to do.