How to determine what is the current Gabarge Collector mode in .NET 4?

The .NET garbage collector has several modes. I would like to know what the default mode for a Windows SKU server is. How to determine what is the current Gabarge Collector mode in .NET 4?

+4
source share
2 answers

The Niranjan answer contains more relevant details, but I believe the answer to your real question is System.Runtime.GCSettings .

It includes properties:

  • IsServerGC - Indicates whether server garbage collection is enabled.
  • LatencyMode - Indicates the current standby mode for garbage collection.
+3
source

I suggest you go through an article by Chris Lyon WebLog How to tell which GC mode is used by your application and Stephen Hollige .NET 4 Garbage Collector .

Introduced in .NET 4: Background [and Foreground] (workstation only)

Starting with the .NET Framework version 4, the background garbage collection replaces the simultaneous garbage collection.

In addition, for more information, you can look at them Scott Hanselman Using the garbage collector (not the workstation) with the .NET Framework (CLR) and this one - Garbage collection modes - GCCollectionMode , Chris Lyon - Server, Workstation and Concurrent GC

Edit:

Que: how to determine what the current Gabarge Collector mode is in .NET 4?

System.Environment.IsServerGC should be used to check on the GC server, System.Runtime.GCSettings.IsServerGC will return true if they were in the GC mode server and false if it was on the workstation.

Que: what is the default mode for a Windows SKU server.

From
Microsoft .NET Framework common language runtime (CLR) uses the Server garbage collector (GC) on multiprocessor computers. This is the default behavior. Server garbage collector is optimized for scalable bandwidth on multiprocessor computers. To reduce competition and improve the performance of the garbage collector on multiprocessor computers, the server garbage collector creates one heap for each processor for parallel collections.

Workstation garbage collector optimized for low latency . Client applications typically require low latency. However, low latency can lead to reduced throughput after configuring the .NET Framework common language runtime to use the Workstation garbage collector.

+2
source

Source: https://habr.com/ru/post/1414086/


All Articles