Foreach in the Mono version used by Unity leaks memory continuously. As such it is recommended to avoid the usage of foreach but instead use normal for loops. In this code we use a ForEach LINQ construct but it should be investigated whether this causes similar memory leaks