gcAllowVeryLargeObjects 的可能缺点?

Possible drawbacks of gcAllowVeryLargeObjects?

在几次 outOfMemory 异常之后,我启用了 "gcAllowVeryLargeObjects",它工作得很好。我现在想知道为什么它不是 C# 中的默认选项(在 64 位平台上)。

是否纯粹出于兼容性原因?还是我遗漏了 gcAllowVeryLargeObjects 的主要缺点?

MSDN 说:

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

因此,只要您不使用 unsafe 代码,就没有缺点。