<Gcallowverylargeobjects> > 元素<gcAllowVeryLargeObjects> Element

在 64 位元平台上,啟用總大小大於 2 GB 的陣列。On 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size.

<configuration> <configuration>
   <執行時間 >   <runtime>
     <gcAllowVeryLargeObjects>    <gcAllowVeryLargeObjects>

語法Syntax

<gcAllowVeryLargeObjects    
   enabled="true|false" />  

屬性和項目Attributes and Elements

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

屬性Attributes

屬性Attribute 說明Description
enabled 必要屬性。Required attribute.

指定在64位平臺上, 是否已啟用大小總計大於 2 GB 的陣列。Specifies whether arrays that are greater than 2 GB in total size are enabled on 64-bit platforms.

啟用屬性enabled Attribute

Value 描述Description
false 未啟用大小總計大於 2 GB 的陣列。Arrays greater than 2 GB in total size are not enabled. 這是預設值。This is the default.
true 64位平臺上已啟用大小總計大於 2 GB 的陣列。Arrays greater than 2 GB in total size are enabled on 64-bit platforms.

子元素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 runtime initialization options.

備註Remarks

在您的應用程式佈建檔中使用此元素, 可讓大小大於 2 GB 的陣列, 但不會變更物件大小或陣列大小的其他限制:Using this element in your application configuration file enables arrays that are larger than 2 GB in size, but does not change other limits on object size or array size:

  • 陣列中的元素數目上限為UInt32.MaxValueThe maximum number of elements in an array is UInt32.MaxValue.

  • 任何單一維度中的最大索引為 2147483591 (0x7FFFFFC7), 適用于位元組陣列和單一位元組結構的陣列, 以及適用于其他類型的 2146435071 (0X7FEFFFFF)。The maximum index in any single dimension is 2,147,483,591 (0x7FFFFFC7) for byte arrays and arrays of single-byte structures, and 2,146,435,071 (0X7FEFFFFF) for other types.

  • 字串和其他非陣列物件的大小上限不變。The maximum size for strings and other non-array objects is unchanged.

警告

啟用這項功能之前, 請確定您的應用程式不包含不安全的程式碼, 其假設所有的陣列大小都小於 2 GB。Before enabling this feature, ensure that your application does not include unsafe code that assumes that all arrays are smaller than 2 GB in size. 例如, 如果不安全的程式碼是以陣列做為緩衝區, 則可能會受到緩衝區溢位的影響, 假設陣列不會超過 2 GB。For example, unsafe code that uses arrays as buffers might be susceptible to buffer overruns if it is written on the assumption that arrays will not exceed 2 GB.

範例Example

下列範例顯示如何為應用程式啟用這項功能。The following example shows how to enable this feature for an application.

<configuration>  
  <runtime>  
    <gcAllowVeryLargeObjects enabled="true" />  
  </runtime>  
</configuration>  

支援於Supported in

.NET Framework 4.5 和更新版本.NET Framework 4.5 and later versions

另請參閱See also