为什么java8中MaxMetaSpaceSize的默认值为18446744073709486080?

Why the defalut value of MaxMetaSpaceSize in java 8 is 18446744073709486080?

我知道 MaxMetaspaceSize 默认是无限制的,对于 Windows x64,最大内存大小是 2^64(18446744073709551616) bytes,所以为什么不将 MaxMetaspaceSize 设置为 2^64 但是将其设置为 18446744073709486080 等于:2^64-2^16?

HotSpot JVM中的“ulimited”大小用适合64位整型变量的最大值表示,即264-1.

MaxMetaSpaceSize 然后进一步 aligned(向下舍入)到最小元空间分配单元

  // Ideally, we would be able to set the default value of MaxMetaspaceSize in
  // globals.hpp to the aligned value, but this is not possible, since the
  // alignment depends on other flags being parsed.
  MaxMetaspaceSize = align_size_down_bounded(MaxMetaspaceSize, _reserve_alignment);

等于 Windows.

上的 64K (216)