$ ./guess_the_languageGame Dev
Game Dev · medium · #262

In C#, why keep millions of particle records as structs in an array?

  1. Structs can't be copied by accident
  2. Structs are garbage collected faster
  3. Arrays of classes can't be sorted
  4. They sit inline with no heap objects
An array of structs is one contiguous block, so there are no per-item objects for the GC to track and iteration is cache-friendly; classes would mean millions of references.
Play Game Dev ▸