3 ms·
You can happily disable the GC for performance-sensitive situations with one line of code: GarbageCollector.GCMode = GarbageCollector.Mode.Disabled; https://do
by glenneroo 4y ago
You can happily disable the GC for performance-sensitive situations with one line of code:
GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
https://docs.unity3d.com/ScriptReference/Scripting.GarbageCollector.GCMode.html https://docs.unity3d.com/ScriptReference/Scripting.GarbageCo...
Then you can call GC.Collect() to garbage collect e.g. between levels.
LINQ is totally fine as long as you don't do it in e.g. Update() which is called every frame. There are lots of other things you start to learn over time such as .transform internally calls GetComponent<Transform>() which in itself isn't a problem but calling it in an Update() on e.g. VR where you have 72-144 frames per second might not be wise especially if you have 10x Update() methods doing this. That's why Unity has had the Profiler for many years - to pinpoint what is causing garbage to pile up and what methods are killing performance.