<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 >   <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 特性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