Configure .NET garbage collection
For good performance, it is important to configure .NET garbage collection for the silo process the correct way. The best combination of settings based on the team's findings is to set gcServer=true
and gcConcurrent=true
. You can configure these values in the C# project (.csproj), or an app.config. For more information, see Flavors of garbage collection.
.NET Core and .NET 5+
This method is not supported with SDK style projects compiling against the full .NET Framework
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>
.NET Framework
SDK style projects compiling against the full .NET Framework should still use this configuration style, consider an example app.config XML file:
<configuration>
<runtime>
<gcServer enabled="true"/>
<gcConcurrent enabled="true"/>
</runtime>
</configuration>
However, this is not as easy to do if a silo runs as part of an Azure Worker Role, which by default is configured to use workstation GC. There's a relevant blog post that discusses how to set the same configuration for an Azure Worker Role, see Server garbage collection mode in Azure.
Important
Server garbage collection is available only on multiprocessor computers. Therefore, even if you configure the garbage collection either via application .csproj file or via the scripts on the referred blog post, if the silo is running on a (virtual) machine with a single-core, you will not get the benefits of gcServer=true
. For more information, see GCSettings.IsServerGC remarks.