3 ms·
What is the technique to do this? Object pools?
by mapmap 5y ago
What is the technique to do this? Object pools?
- throwuxiytayq 5y agoIn case of Unity specifically, yes, re-using entire GameObjects whenever possible goes a long way. In game code, you can use structs instead of managed objects to avoid touching the GC. Unity provides NativeCollections, which are some standard collection data structures that can be used to store structs outside managed memory (which lets you avoid the GC). In real life it's next to impossible to avoid GC completely (especially if you rely on assets/libraries/even built-in engine features), but that isn't the goal - it's enough that you avoid allocating managed objects during gameplay simulation. GC can do its thing during level loading, cutscenes, in UI, etc.
- hackerfromthefu 5y agoYes, also know as Flyweight pattern from GOF. Used in latency sensitive systems like trading engines.