<gcAllowVeryLargeObjects> 元素<gcAllowVeryLargeObjects> element

在 64 位平台上,启用总大小大于 2 千兆字节 (GB) 的数组。On 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size.



<gcAllowVeryLargeObjects enabled="true|false" />  


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


父元素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.


在应用程序配置文件中使用此元素可启用大小大于 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 size 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 arrays containing 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's written on the assumption that arrays will not exceed 2 GB.


下面的示例演示如何为应用程序启用此功能。The following example shows how to enable this feature for an application.

    <gcAllowVeryLargeObjects enabled="true" />  

受以下版本支持:Supported in

.NET Framework 4.5 及更高版本.NET Framework 4.5 and later versions

请参阅See also