3 ms·
GC issues pretty much exist in Unity land only. Other game engines which use vanilla .NET like Stride work without a hitch.
by neonsunset 3y ago
GC issues pretty much exist in Unity land only. Other game engines which use vanilla .NET like Stride work without a hitch.
- VHRanger 3y agoDoes the C# GC have guarantees about when it will/won't run? Dlangs GC for instance guarantee that it will only run on allocation of new memory so it's possible to architect the game to avoid meaningful pauses
- neonsunset 3y agoIn .NET, GC is triggered when a user thread runs out of memory in an allocation budget and needs more, similar to what you described [0]. Generally speaking, indefinitely preventing GC from running is not possible (you always end up putting some data on the heap) therefore an optimal strategy is similar to any other language - limiting allocations and reusing memory through object and array pooling. This will ensure that GC pauses are as infrequent and as short as possible. It's important to note that if there is sufficient allocation budget - the GC will not run. This way, in a well written code the GC may only ever trigger every few hundred frames and only take a millisecond to run. In fact, OSU! has been able to get consistently good frame times even back on .NET Framework. [0] https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/garbage-collection.md https://github.com/dotnet/runtime/blob/main/docs/design/core... [1] https://maoni0.medium.com/dynamically-adapting-to-application-sizes-2d72fcb6f1ea https://maoni0.medium.com/dynamically-adapting-to-applicatio...
- runevault 3y agoI wonder how much of the extra issues Unity has is because it is a very old version of Mono, since more modern versions of .NET have become so much more performant (especially Core 3.1 into 5+). I was sad when .NET 8 came out too late for Godot to fit in the update for Godot 4.2, so I believe they intend to make the update for 4.3.
- DannyWebbie 3y agoUnity is leaving quite a bit on the table by not being on a modern version of .NET. Unity's C++ side seems to have (or had) assumptions about the garbage collection. Progress and challenges on .NET in Unity can be seen in this frequently updated forum thread https://forum.unity.com/threads/unity-future-net-development-status.1092205/ https://forum.unity.com/threads/unity-future-net-development... Unity's long term plan appears to become more tightly integrated with .NET and to avoid maintaining their own .NET stuff.
- runevault 3y agoYeah back before I switched to Godot for my game dev dabbling I was keeping an eye on info about the upgrade to a more modern version of .NET, but I got less and less interested and saw Godot 4 was going to have .NET 6 out the gate so just switched (and all of this was before Unity went full idiot which fully removed any interest I have in going back).