If you want to use 32-bit references, your heap is limited to 32 GB.

However, if you are willing to use 64-bit references, the size is likely to be limited by your OS, just as it is with 32-bit JVM. e.g. on Windows 32-bit this is 1.2 to 1.5 GB.

Note: you will want your JVM heap to fit into main memory, ideally inside one NUMA region. That's about 1 TB on the bigger machines. If your JVM spans NUMA regions the memory access and the GC in particular will take much longer. If your JVM heap start swapping it might take hours to GC, or even make your machine unusable as it thrashes the swap drive.

Note: You can access large direct memory and memory mapped sizes even if you use 32-bit references in your heap. i.e. use well above 32 GB.

Compressed oops in the Hotspot JVM

Compressed oops represent managed pointers (in many but not all places in the JVM) as 32-bit values which must be scaled by a factor of 8 and added to a 64-bit base address to find the object they refer to. This allows applications to address up to four billion objects (not bytes), or a heap size of up to about 32Gb. At the same time, data structure compactness is competitive with ILP32 mode.

Answer from Peter Lawrey on Stack Overflow
🌐
IBM
ibm.com › support › pages › recommended-maximum-heap-sizes-32-and-64-bit-websphere-java-instances
Recommended Maximum Heap Sizes on 32 and 64 bit WebSphere Java instances
*Remember that the WAS Java process ... stacks in general, the recommended Maximum Heap range for WebSphere Application Server, would be between (4096M - 8192M) or (4G - 8G)....
Discussions

What is max heap size I can allocate for Java 64-bit - Oracle Forums
Hi folks, We have the server running 64-bit Linux and Java. What is the highest number of heap size I can set? Let's say the server has 256 G of RAM. Can I allocate 128 GB to Java heap or ever more? ... More on forums.oracle.com
🌐 forums.oracle.com
April 23, 2013
java - JVM heap size not getting more than 1.6 GB for 64 bit JVM - Stack Overflow
Are you really sure that you are using a 64 bit JVM? 1600M sounds pretty much like a typical limit of a 32 bit JVM. You can use the -showversion option to let the JVM print the relevant information without terminating. ... Save this answer. ... Show activity on this post. ... The default initial and maximum heap sizes ... More on stackoverflow.com
🌐 stackoverflow.com
What is the default maximum heap size for Sun's JVM from Java SE 6? - Stack Overflow
What is the default maximum heap size for Sun's JVM from Java SE 6 (i.e. equivalent to setting -Xmx)? Looks like for Java SE 5 with a server-class machine, it's Smaller of 1/4th of the physical ... More on stackoverflow.com
🌐 stackoverflow.com
How is the default max Java heap size determined? - Stack Overflow
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, corresponding to a physical memory size of 128 gigabytes. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Baeldung
baeldung.com › home › java › jvm › could not reserve enough space for object heap
Could Not Reserve Enough Space for Object Heap | Baeldung
January 8, 2024 - The maximum theoretical heap limit for the 32-bit and 64-bit JVM is easy to determine by looking at the available memory space, 2^32 (4 GB) for 32-bit JVM and 2^64 (16 Exabytes) for 64-bit JVM.
🌐
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?
Maximum heap size for 32 bit or 64 bit JVM looks easy to determine by looking at addressable memory space like 2^32 (4GB) for 32 bit JVM and 2^64 for 64 bit JVM. The confusion starts here because you can not really set 4GB as the maximum heap ...
🌐
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, ...
🌐
Oracle
forums.oracle.com › ords › apexds › post › what-is-max-heap-size-i-can-allocate-for-java-64-bit-9150
What is max heap size I can allocate for Java 64-bit - Oracle Forums
April 23, 2013 - Hi folks, We have the server running 64-bit Linux and Java. What is the highest number of heap size I can set? Let's say the server has 256 G of RAM. Can I allocate 128 GB to Java heap or ever more? ...
🌐
IBM
ibm.com › support › pages › largest-possible-maximum-heap-size-websphere-java-64-bit-linux-x86-64
Largest Possible Maximum Heap Size for WebSphere Java 64 Bit on Linux x86-64
Maximum Heap in practice on WAS Linux x86-64 would be approximately -Xmx76t for Java heap because the rest, or 52 TB, is used by Native heap. *There is no Java heap size restriction from JVM, which potentially means there could be a setting as large as a 64-bit platform can address.
🌐
SetGetWeb
setgetweb.com › p › commerce7 › com.ibm.commerce.admin.doc › refs › rpmtuningjvmsettings.htm
JVM performance tuning - setgetweb.com
The tuning and deployment process for the 64-bit JVM can be simplified by not having to tune the disk offload performance. Significant operational savings can be realized for some customers. The ability to increase the maximum heap size beyond 1.5 Gb is beneficial when the store is experiencing ...
Find elsewhere
🌐
Blogger
javarevisited.blogspot.com › 2013 › 04 › what-is-maximum-heap-size-for-32-bit-64-JVM-Java-memory.html
Javarevisited: What is the maximum Heap Size of 32 bit or 64-bit JVM in Windows and Linux?
Theoretical maximum memory for x64 machines is 2^64 bit but again it depends on how much your operating systems allow. I read somewhere that Windows allowed a maximum of 32GB for 64 bit JVM.
🌐
Stack Overflow
stackoverflow.com › questions › 41763128 › jvm-heap-size-not-getting-more-than-1-6-gb-for-64-bit-jvm
java - JVM heap size not getting more than 1.6 GB for 64 bit JVM - Stack Overflow
On 32-bit JVMs, the default maximum heap size can be up to 1 GB if there is 4 GB or more of physical memory. On 64-bit JVMs, the default maximum heap size can be up to 32 GB if there is 128 GB or more of physical memory.
🌐
Java67
java67.com › 2016 › 02 › how-to-increase-heap-size-of-java-program-eclipse-command-line.html
How to Increase Heap Size of Java Program running in Eclipse [Example] | Java67
Practically, you will get around 1.5GB in 32-bit Windows, 2.5GB on 32 bit Linux and slightly more on 32-bit Solaris system. To use a larger heap size, you need to use a 64-bit JVM, where you can theoretically set quite a large heap space.
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
🌐
Medium
medium.com › tier1app-com › does-32-bit-or-64-bit-jvm-matter-anymore-8d14b1b538d4
Does 32-bit or 64-bit JVM matter anymore? | by Ram Lakshmanan | Tier1app.com | Medium
June 10, 2019 - Below table summarizes maximum heap size (i.e. -Xmx) that you can set on 32-bit JVM: Whereas if you are running your application on a 64-bit JVM, maximum addressable memory space is 2⁶⁴ ...
🌐
Blogger
javarevisited.blogspot.com › 2011 › 05 › java-heap-space-memory-size-jvm.html
10 points about Java Heap Space or Java Heap Memory
The default size of Heap space ... throughput garbage collector in Java 1.5 default maximum heap size of JVM would be Physical Memory/4 and the default initial heap size would be Physical Memory/16....
🌐
Oracle
oracle.com › java › technologies
Frequently Asked Questions About the Java HotSpot VM
We have adjusted the defaults for 64-bit implementations to be 30% larger in order to make up for the increased size of Java objects due to larger native pointers. Remember that Java objects contain class and lock pointers so even if you create Java objects which contain only integers, each ...
🌐
javaspring
javaspring.net › blog › maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os
Maximum Java Heap Size for 32-bit JVM on 64-bit OS: Theoretical vs Practical Limits Explained — javaspring.net
In contrast, a 64-bit JVM uses the 64-bit instruction set, enabling much larger heap sizes (often tens or hundreds of GB). The theoretical maximum heap size for a 32-bit JVM is 4GB—the total addressable memory.