About the GC recycling issue in C#

I have a quick question: Does C# GC process garbage collection incrementally across multiple frames? If it doesn’t, would a massive amount of GC cause the game to stutter? I know Unity has an incremental GC strategy, but does the Flax engine have something similar?

C# scripting runs on the latest .NET 10 (unlike Unity, which uses old Mono). On desktop platforms (Windows, Mac, Linux) we use CoreCRL which is the fastest C# runtime with concurrent GC ( Background garbage collection - .NET | Microsoft Learn ). On other platforms (such as Android, iOS, Xbox, PS4/PS5, Switch) we use Mono backend from dotnet runtime, which pauses threads to perform GC collection. However, on some platforms (eg. Switch) we don’t stop threads that are not within C# code (via Cooperative Suspend Runtime Cooperative Suspend | Mono ) which allows to run background code in engine (eg. rendering/streaming) while main thread does some GC work.

2 Likes