Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default max heap size (-Xmx) in Java 8?

Tags:

java

memory

In the oracle documentation I found:

-Xmxsize Specifies the maximum size (in bytes) of the memory allocation pool in bytes ... The default value is chosen at runtime based on system configuration.

What does system configuration mean?

like image 278
Vitaly Avatar asked Feb 02 '15 07:02

Vitaly


People also ask

What is the default max heap size in Java?

The Java™ virtual machine (JVM) heap size setting directly relates to how many server instances can be started within a dynamic cluster on a specific node. You might need to modify the JVM heap size setting based on your environment configuration. The default value is 256 MB.

What is Max XMX in Java?

Sets the maximum memory size for the application (-Xmx >= -Xms). -Xmx size. size can be specified in megabytes (m) or gigabytes (g). For example: -Xmx2g sets a maximum heap size of 2GB.

What is the maximum JVM heap size?

The max JVM heap size limit has been removed since we moved to completely 64 bit releases. As such you are now limited by the OS and/or machine. The theoretical limit is 2^64 bytes, which is 16 exabytes (1 exabyte = 1024 petabytes, 1 petabyte = 1024 terabytes). However, most OS's can't handle that.

What is the maximum heap size for 64 bit JVM?

For 64 bit platforms and Java stacks in general, the recommended Maximum Heap range for WebSphere Application Server, would be between (4096M - 8192M) or (4G - 8G).


1 Answers

It varies on implementation and version, but usually it depends on the VM used (e.g. client or server, see -client and -server parameters) and on your system memory.

Often for client the default value is 1/4th of your physical memory or 1GB (whichever is smaller).

Also Java configuration options (command line parameters) can be "outsourced" to environment variables including the -Xmx, which can change the default (meaning specify a new default). Specifically the JAVA_TOOL_OPTIONS environment variable is checked by all Java tools and used if exists (more details here and here).

You can run the following command to see default values:

java -XX:+PrintFlagsFinal -version 

It gives you a loooong list, -Xmx is in MaxHeapSize, -Xms is in InitialHeapSize. Filter your output (e.g. |grep on linux) or save it in a file so you can search in it.

like image 71
icza Avatar answered Oct 21 '22 05:10

icza