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.

Answer from icza on Stack Overflow
Top answer
1 of 5
175

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.

2 of 5
51

Like you have mentioned, The default -Xmxsize (Maximum HeapSize) depends on your system configuration.

Java8 client takes Larger of 1/64th of your physical memory for your Xmssize (Minimum HeapSize) and Smaller of 1/4th of your physical memory for your -Xmxsize (Maximum HeapSize).

Which means if you have a physical memory of 8GB RAM, you will have Xmssize as Larger of 8*(1/64) and Smaller of -Xmxsizeas 8*(1/4).

You can Check your default HeapSize with

In Windows:

java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"

In Linux:

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

These default values can also be overrided to your desired amount.

🌐
Eclipse OpenJ9 Blog
blog.openj9.org › 2020 › 04 › 30 › default-java-maximum-heap-size-is-changed-for-java-8
Default Java Maximum Heap Size is changed for Java 8 – Eclipse OpenJ9 Blog
April 30, 2020 - From OpenJ9 release 0.20, The default Java Maximum Heap Size (Xmx) is changed to be consistent with Java 11, so by default in Java 8, 25% physical memory up to 25GB for the Xmx will be expected.
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-is-the-default-max-java-heap-size-determined
How is the default max Java Heap size determined? - GeeksforGeeks
July 23, 2025 - Server JVM heap configuration ergonomics are now the same as the Client, except that the default maximum heap size for 32-bit JVMs is 1 gigabyte, corresponding to a physical memory size of 4 gigabytes, and for 64-bit JVMs is 32 gigabytes, ...
🌐
IBM
ibm.com › docs › en › was-nd › 8.5.5
Modifying the JVM heap size - IBM Documentation
February 9, 2026 - Typically, the total value of all server instance JVM heap sizes on a specific node must be less than half of the total RAM of that computer. The default maximum heap size value is 256 MB.
🌐
Baeldung
baeldung.com › home › spring › spring boot › what are the spring boot default memory settings?
What Are the Spring Boot Default Memory Settings? | Baeldung
January 8, 2024 - The Java process or the JVM’s ... there are collected by the garbage collector. The default value for the minimum heap is 8 Mb or 1/64th of the ......
Top answer
1 of 10
669

On Windows, you can use the following command to find out the defaults on the system where your applications runs.

java -XX:+PrintFlagsFinal -version | findstr HeapSize

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

On a Unix/Linux system, you can do

java -XX:+PrintFlagsFinal -version | grep HeapSize

I believe the resulting output is in bytes.

2 of 10
130

For Java SE 5: According to Garbage Collector Ergonomics [Oracle]:

initial heap size:

Larger of 1/64th of the machine's physical memory on the machine or some reasonable minimum. Before J2SE 5.0, the default initial heap size was a reasonable minimum, which varies by platform. You can override this default using the -Xms command-line option.

maximum heap size:

Smaller of 1/4th of the physical memory or 1GB. Before J2SE 5.0, the default maximum heap size was 64MB. You can override this default using the -Xmx command-line option.

UPDATE:

As pointed out by Tom Anderson in his comment, the above is for server-class machines. From Ergonomics in the 5.0 JavaTM Virtual Machine:

In the J2SE platform version 5.0 a class of machine referred to as a server-class machine has been defined as a machine with

  • 2 or more physical processors
  • 2 or more Gbytes of physical memory

with the exception of 32 bit platforms running a version of the Windows operating system. On all other platforms the default values are the same as the default values for version 1.4.2.

In the J2SE platform version 1.4.2 by default the following selections were made

  • initial heap size of 4 Mbyte
  • maximum heap size of 64 Mbyte
🌐
Rlemaitre
rlemaitre.com › articles › til › default-heap-configuration-in-openjdk
Default Heap Configuration in OpenJDK |> Raphaël Lemaitre
June 22, 2025 - For server configurations, as described in the same guide, the default maximum heap size is 1/4 of the physical memory up to 1 gigabyte for 32-bits JVMs and to 32 gigabytes for 64-bits JVMs.
🌐
Oracle
docs.oracle.com › cd › E19900-01 › 819-4742 › abeik › index.html
Heap Tuning Parameters (Sun Java System Application Server Enterprise Edition 8.2 Performance Tuning Guide)
Sun Java System Application Server Enterprise Edition 8.2 Performance Tuning Guide ... The -Xms and -Xmx parameters define the minimum and maximum heap sizes, respectively. Since GC occurs when the generations fill up, throughput is inversely proportional to the amount of the memory available. By default, the JVM grows or shrinks the heap at each GC to try to keep the proportion of free space to the living objects at each collection within a specific range.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › vm › gc-ergonomics.html
Garbage Collection Ergonomics
April 21, 2026 - Smaller of 1/4th of the physical memory or 1GB. Before Java SE 5.0, the default maximum heap size was 64MB.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › tools › unix › java.html
java
April 21, 2026 - By default, this option is enabled, and compressed pointers are used when Java heap sizes are less than 32 GB. When this option is enabled, object references are represented as 32-bit offsets instead of 64-bit pointers, which typically increases performance when running the application with ...
🌐
W3Docs
w3docs.com › java
How is the default max Java heap size determined?
Here is the formula used by the JVM to calculate the default maximum heap size: For systems with less than 1 GB of physical memory, the default maximum heap size is set to 256 MB.
🌐
Medium
medium.com › @maheshwar.ramkrushna › understanding-heap-size-and-its-impact-on-java-application-performance-d4c312bbd13c
Understanding Heap Size and its Impact on Java Application Performance | by Ramkrushna Maheshwar | Medium
May 25, 2023 - By default, the initial heap size of a Java application is set to 1/64th of the computer’s physical memory or a reasonable minimum based on the platform, whichever value is larger.
🌐
Alvin Alexander
alvinalexander.com › blog › post › java › java-xmx-xms-memory-heap-size-control
How to control Java heap size (memory) allocation (xmx, xms) | alvinalexander.com
January 31, 2026 - (The -server flag increases the default size to 2M.) -Xmx size in bytes Sets the maximum size to which the Java heap can grow. The default size is 64M.
🌐
Bell Software
bell-sw.com › blog › guide-to-jvm-memory-configuration-options
List of JVM memory configuration flags
March 14, 2024 - For instance, Alpaquita Linux has ... and 8.77 MB (glibc), perfect for Java microcontainers. Footprint (and startup) optimization is also possible by using Java with CRaC: give it a try!
🌐
Blogger
javarevisited.blogspot.com › 2011 › 05 › java-heap-space-memory-size-jvm.html
10 points about Java Heap Space or Java Heap Memory
So for 1Gig machine maximum heap ... 1GB. 3) for Server Java virtual machine default maximum heap space is 1G for 4GB of physical memory on a 32 bit JVM......
🌐
Baeldung
baeldung.com › home › java › jvm › jvm parameters initialrampercentage, minrampercentage, and maxrampercentage
JVM Parameters InitialRAMPercentage, MinRAMPercentage, and MaxRAMPercentage | Baeldung
June 5, 2024 - For instance, if we set-XX:InitialRAMPercentage=50.0 for a physical server of 1 GB full memory, then the initial heap size will be around 500 MB (50% of 1 GB). To start with, let’s check the default value of the IntialRAMPercentage in the ...
🌐
javaspring
javaspring.net › blog › increase-the-java-heap-size-permanently
How to Permanently Increase Java Heap Size: Set Default JVM Heap to 1GB on Your Computer — javaspring.net
If you set -Xmx larger than your system’s available memory (e.g., 8GB heap on a 4GB laptop), the JVM may fail to start, or your system may slow down due to swapping. Avoid Over-Allocation: Only set heap size to 1GB if your app needs it.