<GCHeapAffinitizeMask > 元素<GCHeapAffinitizeMask> element

定義 GC 堆積與個別處理器之間的親和性。Defines the affinity between GC heaps and individual processors.

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

語法Syntax

<GCHeapAffinitizeMask
   enabled="nnnn"/>

屬性和元素Attributes and elements

下列各節描述屬性、子項目和父項目。The following sections describe attributes, child elements, and parent elements.

屬性Attributes

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

指定 GC 堆積與個別處理器之間的親和性。Specifies the affinity between GC heaps and individual processors.

enabled 屬性enabled attribute

Value 描述Description
nnnn 十進位值,形成位元遮罩,以定義伺服器 GC 堆積與個別處理器之間的親和性。A decimal value that forms a bitmask defining the affinity between server GC heaps and individual processors.

子元素Child elements

無。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元素的限制時,您可以使用GCHeapAffinitizeMask元素來控制伺服器 GC 堆積和處理器之間的相似性。Starting with .NET Framework 4.6.2, you can use the GCHeapAffinitizeMask element to control the affinity between server GC heaps and processors when the number of heaps is limited by the GCHeapCount element.

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

  • GCNoAffinitize,控制是否使用 cpu 相似化為伺服器 GC 執行緒/堆積。GCNoAffinitize, which controls whether server GC threads/heaps are affinitized with CPUs. GCNoAffinitize元素的 enabled 屬性必須是要使用之GCHeapAffinitizeMask設定的 false (其預設值)。The enabled attribute of the GCNoAffinitize element must be false (its default value) for the GCHeapAffinitizeMask setting to be used.

  • GCHeapCount,這會限制進程針對伺服器 GC 所使用的堆積數目。GCHeapCount, which limits the number of heaps used by the process for server GC. 根據預設,每個處理器都有一個堆積。By default, there is one heap for each processor.

nnnn是以十進位值表示的位元遮罩。nnnn is a bit mask expressed as a decimal value. 位0的位元組0代表處理器0,位元組0的位1代表處理器1,依此類推。Bit 0 of byte 0 represents processor 0, bit 1 of byte 0 represents processor 1, and so on. 例如:For example:

<GCHeapAffinitizeMask enabled="1023"/>

1023的值是0x3FF 或 0011 1111 1111b。A value of 1023 is 0x3FF or 0011 1111 1111b. 此程式會使用10個處理器,從處理器0到處理器9。The process uses 10 processors, from processor 0 through processor 9.

範例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, use 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>

請參閱See also