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.

Answer from stones333 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 - In current OpenJ9 release 0.19: For Java 11 and above The Xmx value is 25% of the available memory with a maximum of 25 GB. However, where there is 2 GB or less of physical memory, the value set is 50% of available memory with a minimum value ...
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
Discussions

Wrong default heap size (11.0.4_11 Windows)
Platform: Windows 10 64bit Architecture: x64_windows_hotspot Heap size -Xmx not specified. (Eclipse eclipse.ini) Physical Memory: 4GB OpenJDK11U-jdk_x64_windows_hotspot_11.0.3_7 -> Heap Size 1GB (P... More on github.com
🌐 github.com
34
October 1, 2019
How to increase java' heap size, whatever that is
The Java Virtual Machine (JVM) reserves some amount of memory at startup. This memory is called the heap and is used for objects during runtime. If the JVM doesn't have enough heap memory programs will start throwing OutOfMemoryExceptions and usually crash. You can configure the JVM to reserve more memory at startup with some flags: -Xms256m: This tells the JVM to reserve a minimum of 256 megabytes at startup. If you want to reserve more just increase the amount. 1024m is 1 gigabyte. 2014 is 2 gigabytes. -Xmx1024m: This tells the JVM to not use more than 1024 megabytes during runtime. If your program tries to use more memory then you'll get the OutOfMemoryExceptions explained above. The error you are seeing is likely because -Xms is being set to a larger value than -Xmx. It doesn't make any sense to request more minimum memory than the maximum you've specified, right? I suggest making the values of -Xms and -Xmx the same. More on reddit.com
🌐 r/javahelp
17
3
December 29, 2017
Minecraft server error Invalid initial heap size
You are trying to use 32 bit Java instead of 64 bit Java. 32 bit Java has limitations on how much memory it can use. 64 bit Java does not have this restriction. More on reddit.com
🌐 r/Minecraft
6
1
April 20, 2020
🌐
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.
🌐
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 default size is 2097152 (2MB). The values must be a multiple of, and greater than, 1024 bytes (1KB). (The -server flag increases the default size to 32M.) -Xmn size in bytes Sets the initial Java heap size for the Eden generation. The default value is 640K.
🌐
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.
🌐
GitHub
github.com › AdoptOpenJDK › openjdk-support › issues › 35
Wrong default heap size (11.0.4_11 Windows) · Issue #35 · adoptium/adoptium-support
October 1, 2019 - OpenJDK11U-jdk_x64_windows_hotspot_11.0.3_7 -> Heap Size 1GB (Probably 1/4 of physical memory) OpenJDK11U-jdk_x64_windows_hotspot_11.0.4_11 -> Heap Size 256MB (default?)
Author   adoptium
🌐
W3Docs
w3docs.com › java
How is the default max Java heap size determined?
Since 1 GB is less than the maximum of 1 GB, the default maximum heap size would be set to 1 GB.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › gctuning › factors-affecting-garbage-collection-performance.html
HotSpot Virtual Machine Garbage Collection Tuning Guide
July 15, 2025 - Minimize Java heap size by lowering the values of the options -XX:MaxHeapFreeRatio (default value is 70%) and -XX:MinHeapFreeRatio (default value is 40%) with the command-line options -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio.
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › azure › developer › java › containers › overview
Containerize your Java Applications - Java on Azure | Microsoft Learn
3 weeks ago - The default initial heap size is 1/64 of available memory. These values are valid for OpenJDK 11 and later—and for most distributions, including Microsoft Build of OpenJDK, Azul Zulu, Eclipse Temurin, Oracle OpenJDK, and others.
🌐
Netbrain
netbrain.com › docs › ie80 › help › modifying-jvm-heap-size.htm
Modifying JVM Heap Size
Task Engine runs on JVM (Java Virtual Machine). By default, the JVM heap size is 1GB, which is usually enough to accommodate the data used by Task Engine.
🌐
Blogger
javarevisited.blogspot.com › 2011 › 05 › java-heap-space-memory-size-jvm.html
10 points about Java Heap Space or Java Heap Memory
Heap in Java is generally located ... garbage collection works in Java. The default size of Heap space in Java is 128MB on most of 32 bit Sun's JVM but its highly varies from JVM to JVM e.g....
🌐
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 - For example, we can allocate it to 512 kB: ... In this article, we have learned about the default values of various heap and stack memory configuration options available for Java applications.
🌐
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, ...
🌐
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.
🌐
Skybert
skybert.net › java › default-java-heap-size
Default Java Heap Size | skybert.net
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 ·
🌐
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
For Java 8+ on Windows: Default initial heap size (-Xms): 64MB (or 1/64 of system RAM, whichever is larger). Default maximum heap size (-Xmx): 1GB (or 1/4 of system RAM, whichever is smaller).
🌐
Mkyong
mkyong.com › home › java › find out your java heap memory size
Find out your Java heap memory size - Mkyong.com
March 9, 2014 - In above environment, JVM allocated following default values : Java heap size InitialHeapSize = 64781184 bytes (61.7M) and MaxHeapSize = 1038090240 bytes (990M).
🌐
Oracle
docs.oracle.com › cd › E74363_01 › ohi_vbp_-_installation_guide--20160224-094432-html-chunked › s66.html
2.7.2 JVM Options
Allocating too much memory can lead to lengthy garbage collection pauses and lengthy memory defragmentation (also known as compaction). That in turn may lead to system failures. Make sure that the maximum heap size does not exceed 8192 megabytes.
🌐
Azul
docs.azul.com › prime › Heap-Size
Recommended Heap Size
Intel Ice Lake and newer x86 processors, when 5-level paging (LA57) is enabled at the OS level, can have a maximum heap size of 14000 GB (14 TB). + When ZST is installed, the default value is 1GB and the maximum is 20000GB (20TB). -Xms<size>[m|M|g|G] Starting with 21.07.0.0, this flag specifies ...