What is the Spring Boot default memory settings?

usually its 25% of your total physical memory if no "Xmx" options are provided during java start

On a Unix/Linux system, you can do

java -XX:+PrintFlagsFinal -version | grep HeapSize

On Windows, use the following command to find out the defaults

java -XX:+PrintFlagsFinal -version | findstr HeapSize

Look for the options MaxHeapSize (for -Xmx) and InitialHeapSize for -Xms.

The resulting output is in bytes.


By default Spring Boot app will use JVM default memory settings.

Default heap size

In case your physical memory size is up to 192 megabytes (MB) then default maximum heap size is half of the physical memory.

In case your physical memory size is more than 192 megabytes then default maximum heap size is one fourth of the physical memory.

For example, if your computer has 128 MB of physical memory, then the maximum heap size is 64 MB, and greater than or equal to 1 GB of physical memory results in a maximum heap size of 256 MB.

The maximum heap size is not actually used by the JVM unless your program creates enough objects to require it. A much smaller amount, called the initial heap size, is allocated during JVM initialization. This amount is at least 8 MB and otherwise 1/64th of physical memory up to a physical memory size of 1 GB.

The maximum amount of space allocated to the young generation is one third of the total heap size.

You can check default values specific to you machine with the following command

Linux:

java -XX:+PrintFlagsFinal -version | grep HeapSize

Windows:

java -XX:+PrintFlagsFinal -version | findstr HeapSize

Reference:https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/parallel.html#default_heap_size

Default thread stack size

The default thread stack size varies with JVM, OS and environment variables.

To find out what your default thread stack size is on your platform, use

In Linux:

java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

In Windows:

java -XX:+PrintFlagsFinal -version | findstr ThreadStackSize