Default Java Heap Size


If you don't specify anything with -Xmx and -Xms, how much memory will the operating system allocate to your Java process?

The default heap size was 64MB until Java 5. Since then, it's been calculated runtime. To see what the JVM will pick for your system, you can do:

$ java -XX:+PrintFlagsFinal -version 2>/dev/null |
  grep InitialHeapSize |
  awk '{print $4}' |
  numfmt --to iec
498M

To read more about how this value is calculated, see Garbage Collector Ergonomics


Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🐦 @torsteinkrause