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
๐ŸŒ
Informatica Knowledge
knowledge.informatica.com โ€บ s โ€บ article โ€บ 621278
FAQ: What is maximum heap size (-XMX) value can be specified for an ILM java process in startApplimation script which is used to start the service
May 18, 2022 - Memory is nothing to do with a signed or unsigned bit as there is no negative memory address. So the theoretical limit for maximum heap size on 32 bit JVM is 4GB and for 64 bit JVM it is 2^64. โ€‹ ... FAQ: What is maximum heap size (-XMX) value can be specified for an ILM java process in ...
๐ŸŒ
ycrash Answers
answers.ycrash.io โ€บ question โ€บ what-is-maximum-heap-size--xmx-
What is Maximum Heap Size: -Xmx? - yCrash Answers
Temurin-17.0.3+7 (build 17.0.3+7) OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode) This shows the maximum heap size as 4294967296 bytes, or 4Gb. ... The value of -Xmx cannot be lower than -Xms (initial/minimum heap ...
๐ŸŒ
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?
So the theoretical limit for maximum heap size on 32 bit JVM is 4GB and for 64 bit JVM it's 2^64. Why JVM not able to start on Windows XP when maximum heap space around 1600M? This problem is most obvious on Windows platforms like Windows XP, ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 19176761 โ€บ is-there-a-limit-on-xms-and-xmx-settings-for-64-bit-os
jboss - Is there a limit on XMS and XMX settings for 64 bit OS - Stack Overflow
I have read about issues with garbage collection. The server has 24gig. ... I am running 65536M on 2008 R2 64-bit with no issues. Machine has 32GB physical (well, it's actually a VM, so it's virtual, but what isn't?).
๐ŸŒ
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 - This target range is set as a percentage by the options -XX:MinHeapFreeRatio=<minimum> and -XX:MaxHeapFreeRatio=<maximum>, and the total size is bounded below by โ€“Xms<min> and above by โ€“Xmx<max>. The default options for the 64-bit Solaris operating system (SPARC Platform Edition) are shown in Table 4-1.
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.

Find elsewhere
๐ŸŒ
The Coding Forums
thecodingforums.com โ€บ archive โ€บ archive โ€บ java
How is the max value that you can set with the -Xmx param for heap size of the java jvm determined? | Java | Coding Forums
February 3, 2007 - On the Solaris box I happen to be using at the moment I can get to -Xmx3908m, about 90% of the full 4GB. Windows and Linux and Mac and whatever may have different limits. (Yes, Solaris is a 64-bit O/S.
๐ŸŒ
Getisymphony
docs.getisymphony.com โ€บ bin โ€บ view โ€บ iSymphony 3.5 Documentation โ€บ iSymphony Installation and Update Guide โ€บ Installing iSymphony โ€บ Advanced Installation Topics โ€บ Increasing JVM maximum memory allocation
Increasing JVM maximum memory allocation - XWiki
September 9, 2021 - Depending upon the kind of operating system you are running, the maximum value you can set for the Java heap can vary. ... If you do not add a unit, you will get the exact value you state; for example, 64 will be interpreted as 64 bytes, not 64 megabytes or 64 kilobytes. The -Xmx option and ...
Top answer
1 of 3
22

There is a distinction between allocating the memory and allocating the address space. The Oracle JVM is allocating the address space on startup to ensure the heap is contiguous. This allows for certain optimizations to be used with the heap.

If the allocation fails, then Java won't start... as you have seen. It isn't necessarily using that much memory, but it is allocating the required address space up-front. Since you are passing -Xmx1536m, it is saying ok, I need to allocate that in case you need it... and since it must be contiguous it does it up-front so it can guarantee it (or fails trying).

This behavior is the same on both 32-bit and 64-bit JVMs. What you are seeing is the 2GB per-process address space limitation of 32-bit processes (at least, on Windows this is the limitation - it may be slightly larger on other platforms) causing this allocation to fail on 32-bit, where 64-bit has no issues since it has much larger address space. But, you say, 1536m is less than 2GB, I should be good, right? Not quite - the heap is not the only thing being allocated in the address space, DLLs and other stuff is also allocated in the address space...so getting a contiguous 1536m chunk out of 2GB max on 32-bit is unfortunately very unlikely. I've seen values below 1000m fail on 32-bit processes with particularly bad fragmentation, and usually 1200-1300m is the max heap you can specify on 32-bit.

On modern OSes, ASLR (Address Space Layout Randomization) makes fragmentation of 32-bit process address space worse. It intentionally loads DLLs into random addresses for security reasons... making it even less likely you can get a big, contiguous heap in 32-bit.

In 64-bit, the address space is so large that fragmentation is no longer a problem and giant heaps can be allocated without issues. Even if you have 4GB of RAM on 32-bit, though, the 2GB per process address space limitation (at least on Windows) usually means the max heap is usually only 1300m or so.

2 of 3
7

Actually, the application is not allocating the Xmx memory at startup.

The -Xms parameter configure the startup memory. (What are the Xms and Xmx parameters when starting JVMs?)

The 64bit environment allows a bigger memory allocation then 32bits. But, in fact, it's using the HD space, not the memory ram.

See this other post for more info.

Estimating maximum safe JVM heap size in 64-bit Java

๐ŸŒ
Heaphero
blog.heaphero.io โ€บ home โ€บ does 32-bit or 64-bit jvm matter anymore?
DOES 32-BIT OR 64-BIT JVM MATTER ANYMORE? - HeapHero โ€“ Java & Android Heap Dump Analyzer
September 16, 2025 - 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^64 (i....
๐ŸŒ
IBM
ibm.com โ€บ docs โ€บ en โ€บ sdk-java-technology โ€บ 8
-Xms / -Xmx - IBM Documentation
January 22, 2026 - But now with current adjustment, the default maximum heap size is increased automatically to 6 GB and the VM starts. This change in behavior was added from the 0.53.0 release onwards.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 504688 โ€บ java โ€บ Mamimum-allowed-XMX-Parameter
Mamimum Value which can be allowed in -XMX Parameter (Java in General forum at Coderanch)
So what is the parametr in the ... to pass value greater than 4 GB I suppose.. When I upgraded it to 64 Bit then I am able tyo pass value as big as 8 GB.....
Top answer
1 of 4
36

Yes, there is a maximum, but it's system dependent. Try it and see, doubling until you hit a limit then searching down. At least with Sun JRE 1.6 on linux you get interesting if not always informative error messages (peregrino is netbook running 32 bit ubuntu with 2G RAM and no swap):

peregrino:$ java -Xmx4096M -cp bin WheelPrimes 
Invalid maximum heap size: -Xmx4096M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.

peregrino:$ java -Xmx4095M -cp bin WheelPrimes 
Error occurred during initialization of VM
Incompatible minimum and maximum heap sizes specified

peregrino:$ java -Xmx4092M -cp bin WheelPrimes 
Error occurred during initialization of VM
The size of the object heap + VM data exceeds the maximum representable size

peregrino:$ java -Xmx4000M -cp bin WheelPrimes 
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

(experiment reducing from 4000M until)

peregrino:$ java -Xmx2686M -cp bin WheelPrimes 
(normal execution)

Most are self explanatory, except -Xmx4095M which is rather odd (maybe a signed/unsigned comparison?), and that it claims to reserve 2686M on a 2GB machine with no swap. But it does hint that the maximum size is 4G not 2G for a 32 bit VM, if the OS allows you to address that much.

2 of 4
5

I think a 32 bit JVM has a maximum of 2GB memory.This might be out of date though. If I understood correctly, you set the -Xmx on Eclipse launcher. If you want to increase the memory for the program you run from Eclipse, you should define -Xmx in the "Run->Run configurations..."(select your class and open the Arguments tab put it in the VM arguments area) menu, and NOT on Eclipse startup

Edit: details you asked for. in Eclipse 3.4

  1. Run->Run Configurations...

  2. if your class is not listed in the list on the left in the "Java Application" subtree, click on "New Launch configuration" in the upper left corner

  3. on the right, "Main" tab make sure the project and the class are the right ones

  4. select the "Arguments" tab on the right. this one has two text areas. one is for the program arguments that get in to the args[] array supplied to your main method. the other one is for the VM arguments. put into the one with the VM arguments(lower one iirc) the following:
    -Xmx2048m

    I think that 1024m should more than enough for what you need though!

  5. Click Apply, then Click Run

  6. Should work :)

๐ŸŒ
Medium
medium.com โ€บ @marketing_864 โ€บ best-practices-java-memory-arguments-for-containers-1d704a65f7db
Best practices: Java memory arguments for Containers | by Ram Lakshmanan | Medium
December 17, 2020 - # java -Xmx512m -XshowSettings:vm -version VM settings: Max. Heap Size: 512.00M Ergonomics Machine Class: client Using VM: OpenJDK 64-Bit Server VM
๐ŸŒ
Codecurmudgeon
codecurmudgeon.com โ€บ wp โ€บ 2012 โ€บ 05 โ€บ java-memory-settings-jvm-heap-size
Java Memory Settings โ€“ JVM Heap Size โ€“ Code Curmudgeon
HaystackThe amount of memory available to the application is known as the Java heap size and is controlled by passing the -Xms and -Xmx flags to the virtual machine. The Xms is the starting heap size, the Xmx is the maximumum heap size.
๐ŸŒ
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
-Xmx8G (process size could be around 12G on a busy AppServer) Caveat: This blog entry was primarily created for WebSphere Base and Network Deployment full version products, but I wanted to also quickly point out that when using some of our stack products such as Business Process Monitor (BPM), ...
๐ŸŒ
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 - First, by using Java command line parameters at each JVM initialization: -Xms<size> Sets initial Java heap size. This value must be a multiple of 1024 and greater than 1 MB. -Xmx<size> Sets maximum Java heap ...