<GCHeapCount > 元素<GCHeapCount> element

指定要用於伺服器垃圾收集的堆積/執行緒數目。Specifies the number of heaps/threads to use for server garbage collection.

<設定 > <configuration>
  <執行時間 >   <runtime>
    <GCHeapCount >    <GCHeapCount>

語法Syntax

<GCHeapCount
   enabled="nn"/>

屬性和元素Attributes and elements

下列章節說明屬性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

屬性Attributes

屬性Attribute 描述Description
enabled 必要屬性。Required attribute.

指定要用於伺服器垃圾收集的堆積數目。Specifies the number of heaps to use for server garbage collection. 實際的堆積數目是您指定之堆積數目的最小值,以及您的進程允許使用的處理器數目。The actual number of heaps is the minimum of the number of heaps you specify and the number of processors your process is allowed to use.

enabled 屬性enabled attribute

Value 描述Description
nn 用於伺服器 GC 的堆積數目。The number of heaps to use for server GC.

子元素Child elements

None。None.

父元素Parent elements

項目Element 描述Description
configuration 通用語言執行平台和 .NET Framework 應用程式所使用之每個組態檔中的根項目。The root element in every configuration file used by the common language runtime and .NET Framework applications.
runtime 包含有關組件繫結和記憶體回收的資訊。Contains information about assembly binding and garbage collection.

備註Remarks

根據預設,伺服器 GC 執行緒會相似化為其各自的 CPU,讓每個處理器都有一個 GC 堆積、一個伺服器 GC 執行緒,以及一個背景伺服器 GC 執行緒。By default, server GC threads are hard-affinitized with their respective CPU so that there is one GC heap, one server GC thread, and one background server GC thread for each processor. 從 .NET Framework 4.6.2 開始,您可以使用GCHeapCount元素來限制應用程式用於伺服器 GC 的堆積數目。Starting with .NET Framework 4.6.2, you can use the GCHeapCount element to limit the number of heaps used by your application for server GC. 限制用於伺服器 GC 的堆積數目,對於執行多個伺服器應用程式實例的系統特別有用。Limiting the number of heaps used for server GC is particularly useful for systems that run multiple instances of a server application.

GCHeapCount通常會與兩個其他旗標搭配使用:GCHeapCount is typically used along with two other flags:

如果已設定GCHeapCount ,且GCNoAffinitize已停用(其預設值),則nn GC threads/堆積和第一個nn個處理器之間會有相似性。If GCHeapCount is set and GCNoAffinitize is disabled (its default setting), there is an affinity between the nn GC threads/heaps and the first nn processors. 您可以使用GCHeapAffinitizeMask元素來指定進程的伺服器 GC 堆積所使用的處理器。You can use the GCHeapAffinitizeMask element to specify which processors are used by the process's server GC heaps. 否則,如果有多個伺服器進程在系統上執行,其處理器使用量將會重迭。Otherwise, if multiple server processes are running on a system, their processor usage will overlap.

如果已設定GCHeapCount並啟用GCNoAffinitize ,垃圾收集行程會限制用於伺服器 GC 的處理器數目,但不會將相似化為 GC 堆積和處理器。If GCHeapCount is set and GCNoAffinitize is enabled, the garbage collector limits the number of processors used for server GC but does not affinitize GC heaps and processors.

範例Example

下列範例指出應用程式使用具有10個堆積/執行緒的伺服器 GC。The following example indicates that an application uses server GC with 10 heaps/threads. 由於您不想讓這些堆積與系統上執行的其他應用程式的堆積重迭,因此,您可以使用GCHeapAffinitizeMask來指定進程應該使用 cpu 0 到9。Since you don't want those heaps to overlap with heaps from other applications running on the system, you use the GCHeapAffinitizeMask to specify that the process should use CPUs 0 through 9.

<configuration>
   <runtime>
      <gcServer enabled="true"/>
      <GCHeapCount enabled="10"/>
      <GCHeapAffinitizeMask enabled="1023"/>
   </runtime>
</configuration>

下列範例不會將相似化為伺服器 GC 執行緒,而且會將 GC 堆積/執行緒的數目限制為10。The following example does not affinitize server GC threads and limits the number of GC heaps/threads to 10.

<configuration>
   <runtime>
      <gcServer enabled="true"/>
      <GCHeapCount enabled="10"/>
      <GCNoAffinitize enabled="true"/>
   </runtime>
</configuration>

另請參閱See also