You are using 32 bit VM (Java HotSpot(TM) Client VM) which can be mapped to maximum 4G (Only 2 GB in reality) 2^32 address locations Maximum Java heap size of a 32-bit JVM on a 64-bit OS

Error message suggest you are using 5GB heap memory which is not supported on 32 bit architecture

Invalid maximum heap size: -Xmx5096m The specified size exceeds the maximum representable size.

Could not create the Java virtual machine.

You can modify the -Xmx parameter to use anythinng <=2g should work here

Answer from Fairoz on Stack Overflow
🌐
Reddit
reddit.com › r/admincraft › invalid maximum heap size
r/admincraft on Reddit: Invalid maximum heap size
February 7, 2026 -

I wanted to run a minecraft paper server 1.21.11 on my laptop. I set it up, everything looks fine and I get this error:
Invalid maximum heap size: -Xmx4G

The specified size exceeds the maximum representable size.

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.
Also, it worked on my previous laptop, but doesn`t work on this one. Here is the .bat file:
java -Xms2G -Xmx4G -jar papermc-server.jar

Edit: it works if i delete the -Xms and -Xmx flags, but then it automatically assigns the heap to: 676/5984

Discussions

java - Invalid maximum heap size: -XX:MaxHeapSize=4096m - Game Development Stack Exchange
I am trying to package android project in UE4.27. And getting this I tried changing environment variable _JAVA_OPTIONS: -Xmx512M -Xms512M not worked. Where can I change MaxHeapSize, please tell me More on gamedev.stackexchange.com
🌐 gamedev.stackexchange.com
Invalid maximum heap size: -Xmx4096M and other errors

This is usually caused by having 32 bit Java Install rather than 64 bit.

From a command prompt, type the following command: java -version

The third line should say, "Java HotSpot(TM) 64-Bit Server VM". If you don't see "64-Bit", then you're running 32 bit.

You can download and install 64 bit java here: (Link)

More on reddit.com
🌐 r/Minecraft
2
3
July 29, 2020
Invalid Maximum Heap Size even though I have the RAM and 64 bit Java - Server Support and Administration - Support - Minecraft Forum - Minecraft Forum
I'm trying to run a modded Forge server in 1.16.5 and I keep getting this error: C:\Users\Desktop\SERVER>java -Xmx8G -Xms4G -jar forgeserver.jar nogui ... More on minecraftforum.net
🌐 minecraftforum.net
Can't set MEMORY for server — "invalid maximum heap size"
Describe the problem Relevant line: Invalid maximum heap size: -Xmx8GB Container definition services: mc: user: 1001:1001 image: itzg/minecraft-server tty: true stdin_open: true ports: - "2556... More on github.com
🌐 github.com
7
June 7, 2024
🌐
GitHub
github.com › Ajarmar › universal-pokemon-randomizer-zx › issues › 339
[Help] Invalid Maximum Heap Size - Xmx4096m · Issue #339 · Ajarmar/universal-pokemon-randomizer-zx
November 19, 2021 - [Help] Invalid Maximum Heap Size - Xmx4096m#339 · Copy link · NcGamer69 · opened · on Nov 19, 2021 · Issue body actions ·
Author   Ajarmar
🌐
PeopleFluent
support.peoplefluent.com › hc › en-us › articles › 34454398034201-Java-heap-space-error-Common-errors-in-setting-Java-Heap-Size
Java heap space error : Common errors in setting Java Heap Size – PeopleFluent
The heap size is larger than JVM thinks you would ever need. For example, java -Xmx256g BigApp Invalid maximum heap size: -Xmx256g The specified size exceeds the maximum representable size. Could not create the Java virtual machine.
Find elsewhere
🌐
Google Groups
groups.google.com › g › akka-user › c › uw4mJVmE_BE
Invalid maximum heap size
Invalid maximum heap size indicates there's something wrong with your -Xmx argument.
🌐
SAP
userapps.support.sap.com › sap › support › knowledge › en › 1940204
1940204 - Invalid maximum heap size: -Xmx | SAP Knowledge Base Article
Execution of the command "/bin/sh ... 'sdmguiport=50218' 'sdmhome=/usr/sap/BIQ/DVEBMGS02/SDM/program' Invalid maximum heap size: -Xmx Could not create the Java virtual machine....
🌐
Minecraft Forum
minecraftforum.net › home › minecraft forum › support › server support and administration › invalid maximum heap size even though i have the ram and 64 bit java
Invalid Maximum Heap Size even though I have the RAM and 64 bit Java - Server Support and Administration - Support - Minecraft Forum - Minecraft Forum
C:\Users\Desktop\SERVER>java -Xmx8G -Xms4G -jar forgeserver.jar nogui Invalid maximum heap size: -Xmx8G The specified size exceeds the maximum representable size. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred.
🌐
Blogger
javarevisited.blogspot.com › 2012 › 12 › invalid-initial-and-maximum-heap-size.html
Invalid initial and maximum heap size in JVM - How to Fix
64 bit JVM installed on Solaris machines runs with a 32-bit model if you don't specify either -d32 or -d64, which won't accept a Maximum heap size of 4GB, hence "invalid heap size".
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206835365-Invalid-maximum-heap-size-Xmx8192m
Invalid maximum heap size: -Xmx8192m – IDEs Support (IntelliJ Platform) | JetBrains
January 15, 2015 - So, I changed the max heap size from 750m to 2048m. When i changed this, I was unable to start the intellij. Invalid maximum heap size: -Xmx2048m The specified size exceeds the maximum representable size.
🌐
GitHub
github.com › itzg › docker-minecraft-server › issues › 2880
Can't set MEMORY for server — "invalid maximum heap size" · Issue #2880 · itzg/docker-minecraft-server
June 7, 2024 - Describe the problem Relevant line: Invalid maximum heap size: -Xmx8GB Container definition services: mc: user: 1001:1001 image: itzg/minecraft-server tty: true stdin_open: true ports: - "2556...
Author   itzg
🌐
Bukkit
bukkit.org › threads › invalid-maximum-heap-size.256994
Invalid Maximum Heap Size | Bukkit Forums
April 14, 2014 - Hey guys, I'm trying to keep a private server up for me and my friends but i wanted to increase the RAM allocated to the server, when I do, i get this...
🌐
Minecraft Forum
minecraftforum.net › home › minecraft forum › support › server support and administration › invalid maximum heap size
invalid maximum heap size - Server Support and Administration - Support - Minecraft Forum - Minecraft Forum
Quote from Zaine2 The error pops up when i run my server. invalid maximum heap size -Xmx5120m the specified size exceeds the maximum representable size. could not create the jana virtual machine.
🌐
FreeBSD
forums.freebsd.org › development › userland programming and scripting
Solved - Java Specify Heap Size OpenJDK11 | The FreeBSD Forums
March 1, 2021 - I'm attempting to run a simple Java application with a specified max heap size (the system has more than 60GB free): $ /usr/local/bin/java -Xmx1024m:. com.company.Main Invalid maximum heap size: -Xmx1024m:. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred...
🌐
FileBot
filebot.net › forums › help and support
Invalid maximum heap size: -Xmx6538m - FileBot
filebot -script 'fn:sysinfo' --log-file '/usr/local/filebot-node/data/filebot.log' ------------------------------------------ Invalid maximum heap size: -Xmx6538m The specified size exceeds the maximum representable size. Error: Could not create the Java Virtual Machine.
🌐
GitHub
github.com › Ajarmar › universal-pokemon-randomizer-zx › issues › 569
Xmx4608M The specified size exceeds the maximum ...
November 11, 2022 - [Help]When ever i double click the file this is what it says Invalid maximum heap size: -Xmx4608M The specified size exceeds the maximum representable size. Error: Could not create the Java Virtual Machine.
Author   Ajarmar