如何确定.NET 4中当前的Gabarge收集器模式?

.NET垃圾收集器有几种模式。我想知道什么是Windows Server SKU的默认模式。如何确定.NET 4中当前的Gabarge收集器模式?

0
额外
意见: 1

2 答案

Niranjan的答案包括更多相关的细节,但我相信你的实际问题的答案是 <�代码> System.Runtime.GCSettings </代码>

它包括以下属性:

  • IsServerGC - Indicates whether server garbage collection is enabled.
  • LatencyMode - Indicates the current latency mode for garbage collection.
0
额外
这也适用于.NET Framework 2.0(我没有检查早期版本)。
额外 作者 SharpC,

我建议你通过Chris Lyon的WebLog文章如何辨别您的应用程序使用哪种GC模式和Steven Hollidge的垃圾Collector .NET 4

在.NET 4中引入:背景[和前景](仅限工作站)

     

从.NET Framework版本4开始,后台垃圾   集合取代了并发垃圾收集。

Moreover, for more information you can look these Scott Hanselman's Using the Server (rather than Workstation) Garbage Collector with the .NET Framework (CLR) and this one - Garbage Collection Modes - GCCollectionMode, Chris Lyon's - Server, Workstation and Concurrent GC

Edit:

Que:如何确定当前的Gabarge收集器模式   .NET 4?

System.Environment.IsServerGC should be used to check against Server GC, the System.Runtime.GCSettings.IsServerGC will return true if we’re in server GC mode, and false if in workstation.

Que:Windows Server SKU的默认模式是什么。

From
The Microsoft .NET Framework common language runtime (CLR) uses the Server garbage collector (GC) on multiprocessor computers. This is the default behavior. The Server garbage collector is optimized for scalable throughput on multiprocessor computers. To reduce contention and to improve garbage collector performance on multiprocessor computers, the Server garbage collector creates one heap per processor for parallel collections.

The Workstation garbage collector is optimized for low latency. Low latency is typically required for client applications. However, low latency may cause decreased throughput after you configure the .NET Framework common language runtime to use the Workstation garbage collector.

0
额外
如果我们处于服务器GC模式, System.Runtime.GCSettings.IsServerGC 将返回true,如果在工作站中,则返回false。这里放置解释链接而不是复制贴图是好事。
额外 作者 Niranjan Kala,