1

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?

Nilushan Costa
  • 286
  • 2
  • 6
  • 24

1 Answers1

4

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.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Thank you @apangin. The default value of `MaxHeapSize` is a fraction of the size of memory. Is there a reason why `MaxMetaspaceSize` default is set to unlimited instead of a fraction of memory similar to `MaxHeapSize`? – Nilushan Costa Jun 02 '20 at 10:31
  • 1
    @NilushanCosta One of the primary goals of the Metaspace was to remove PermGen and avoid the need to tune its size. See [JEP 122](http://openjdk.java.net/jeps/122) for details. – apangin Jun 02 '20 at 11:12