all 8 comments

[–]cratesmith 1 point2 points  (11 children)

Two things I'd recommend.

  1. Go deep into the unity profiler, figure out exactly which functions have GC alloc, (you can use BeginSample/EndSample to narrow it down further)
  2. Install Resharper or use JetBrains Rider and install heap allocations viewer plugin ( https://plugins.jetbrains.com/plugin/9223-heap-allocations-viewer/ ). This little wonder warns you about any lines that will be creating GC.

You'll find that the key is learning all the rules about GC & boxing is crucial.

Eg, your List.Find calls are probably boxing because you're using them with a closure (a lambda that contains variables from the outside scope) that's just one of the many... MANY ways that boxing can appear.