In C#, why keep millions of particle records as structs in an array?
- Structs can't be copied by accident
- Structs are garbage collected faster
- Arrays of classes can't be sorted
- 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 ▸