<gcAllowVeryLargeObjects > 元素<gcAllowVeryLargeObjects> Element

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

<配置 > 元素<configuration> Element
<运行时 > 元素<runtime> Element
<gcAllowVeryLargeObjects > 元素<gcAllowVeryLargeObjects> Element


   enabled="true|false" />  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.


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

  • 在任何单个维度中的最大索引是 2,147,483,591 (0x7FFFFFC7) 的字节数组和单字节结构的数组和 2,146,435,071 (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.


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

    <gcAllowVeryLargeObjects enabled="true" />  

请参阅See also