Hey community!
Our application has to run for days or even weeks in worst case without issues (memory and performance).
In most cases we at least have once per day the possibility to restart our unity application.
While doing tests around the restarting our testing team found a really strange behaviour that we are currently investigating.
Once out of like 50 times it can happen that we run into a memory issue.
The strange thing is, in those runs the memory is continuously increasing directly form the startup even without doing anything on the application itself.
To give a little context to the project:
Unity is the Client Part that connects to multiple server instances (C# applications).
The server instances running basically our game flows and unity visualize it and let the user interact with the game.
So also with no interactions to the application there is still stuff going on.
It runs then for around 2 hours continuesly eating more memory until it finally runs out of memory.
I managed once to catch a memory dump with the memory profiler that showed the following output:
(Snapshot A is the game with the issue running for about 1h, Snapshot B is the same game, with the same setup/hardware running already more than 4-5h)
So it seems like that we have an issue with heap fragmentation. Just sometimes?
After analyzing the memory dump without finding anything that looks unusal in comparison to the normal running dump we did some investigations about the Garbage Collector.
We had alread from previous games some tooling in place that shows how often GC.Collect was called (basically GC.CollectionCount(0), (1) and (2)) and we found out that for those runs where the game starts using more and more memory the result of GC.CollectionCount(0) just stops increasing at around 40 collections? (Currently testing if thats also the case for Count(1) and Count(2))
We also already tried to manually call GC.Collect in case we notice that the memory increases but the collection count stays. But even when manually called, the count does not increase anymore and the memory usage continuesly grows.
I really donât know what i sould think about that so iâm hoping to get some input or ideas what i could start looking into or if maybe someone also experienced once an issue like that.
Some Facts:
- Unity 2020.3 LTS
- Incremental Garbage Collector â deactivated
- Build Target: Windows
