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
🌐
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.
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.

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
🌐
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.
🌐
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 - The default maximum heap size is half of the physical memory up to a physical memory size of 192 megabytes and otherwise one-fourth of the physical memory up to a physical memory size of 1 gigabyte.
🌐
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 - Heap is the part of the memory where the objects live until there are collected by the garbage collector. The default value for the minimum heap is 8 Mb or 1/64th of the physical memory within the 8 Mb to 1 Gb range.
🌐
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.
🌐
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.
Find elsewhere
🌐
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 128M.) The maximum heap limit is about 2 GB (2048MB). When setting the Java heap size, you should specify your memory argument using one of the letters “m” or “M” for MB, or “g” or “G” for GB.
🌐
W3Docs
w3docs.com › java
How is the default max Java heap size determined?
For systems with 1 GB or more of physical memory, the default maximum heap size is set to 1/4 of the physical memory up to a maximum of 1 GB. For example, on a system with 4 GB of physical memory, the default maximum heap size would be calculated ...
🌐
Azul
docs.azul.com › prime › Heap-Size
Recommended Heap Size
The default value is 1.5625% of the total system memory or cgroup/container limit, and ranges from a minimum 128 MB to a maximum 2 GB. When ZST is installed, this parameter is ignored and the minimum heap size is equal to -Xmx, except when heap elasticity is enabled.
🌐
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.
🌐
javaspring
javaspring.net › blog › how-to-identify-default-java-heapsize-in-windows
How to Identify Default Java Heap Size in Windows: Command Prompt Method for Eclipse Applications — javaspring.net
Default maximum heap size (-Xmx): 1GB (or 1/4 of system RAM, whichever is smaller). ... Windows OS: Windows 10/11 (32-bit or 64-bit). Eclipse Installed: Any recent version (e.g., Eclipse 2023-09).
🌐
Blogger
javarevisited.blogspot.com › 2013 › 04 › what-is-maximum-heap-size-for-32-bit-64-JVM-Java-memory.html
What is the maximum Heap Size of 32 bit or 64-bit JVM in Windows and Linux?
In Java 8 up to 64 GiB. ... Rajasekar said... I have doubt from the question 2 you have mentioned that Java runs out of memory if xmx is 1600mb in windows. But in question 5 you have mentioned that OS will use swap memory in harddisk if it crosses ...
🌐
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 - We recommend increasing the maximum heap allocation to 512 MB or 1024 MB when dealing with discovery ranges equivalent to a class B subnet, or in excess of 30,000 addressable devices. This is because the default maximum Java heap size is 256 MB, ...
🌐
Baeldung
baeldung.com › home › java › jvm › guide to the most important jvm parameters
Guide to the Most Important JVM Parameters | Baeldung
January 8, 2024 - We can mark units as ‘g’ for GB, ‘m’ for MB, and ‘k’ for KB. For example, if we want to assign minimum 2 GB and maximum 5 GB to JVM, we need to write: ... Starting with Java 8, the size of Metaspace isn’t defined.
🌐
javaspring
javaspring.net › blog › java-default-heap-size
Java Default Heap Size: A Comprehensive Guide — javaspring.net
The heap is divided into different generations, mainly the Young Generation, Old Generation, and Permanent Generation (in Java 7 and earlier, replaced by Metaspace in Java 8 and later). The default heap size in Java varies depending on the Java Virtual Machine (JVM) implementation, operating ...