javajvmmetaspace

Why is the default MaxMetaspaceSize on Java very large?


I checked the default MaxMetaspaceSize on the JVM by printing JVM parameters as follows

java -XX:+PrintFlagsFinal -version | grep MaxMetaspaceSize
    uintx MaxMetaspaceSize                          = 18446744073709547520                    {product}
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

Given that these JVM parameter values are shown in bytes, the default MaxMetaspaceSize is about 18 Exabytes!

Can someone please explain why the default MaxMetaspaceSize value is so large?


Solution

  • 18446744073709547520 = 0xFFFFFFFFFFFFF000

    This is basically the maximum possible 64-bit integer (rounded to the page size).
    The idea is to have MaxMetaspaceSize unlimited by default.