When we switched from mono to IL2CPP on Windows 64bit Standalone on 2018.3.5f1, we’ve noticed some FPS increase, but in some scenarios (complex game scenes) automatic GC is called each 9 frames and takes over 50ms each time. This is very annoying in game 60+ FPS game.
We’ve managed to disable automatic GC by
UnityEngine.Scripting.GarbageCollector.GCMode
and we can trigger System.GC.Collect when we want (default behaviour is probably optimized for mobiles).
We want to run GC once in a few minutes or when used memory reaches some threshold (like 1GB), as we could afford higher memory consumption rather then frequent FPS drops on PCs.
However doing so leads to “Too Many Heap Sections” error. So I want to ask:
- What EXACTLY are Heap Sections (I cannot settle with answer like you can only allocate 3.5GB memory)
- How can I monitor the number of Heap Sections I have currently used
- What is the maximum amount of Heap Sections, and how can I change it (at compile time)
Thanks!