Applies to: Minecraft: Java Edition 26.3 (official launcher and dedicated server; server tested on AlmaLinux 9 with Java 25)
Minecraft: Java Edition runs in Java, and Java only uses as much memory as its maximum heap allows, set with -Xmx. The launcher sets 2 GB by default, which is enough for the plain game but often too little for modpacks or a busy server. Bedrock Edition has no such setting.
In the Minecraft Launcher
- Open the launcher, select Minecraft: Java Edition and click the Installations tab.
- Hover over the installation you use (for example your Fabric one), click the three dots and choose Edit.
- Click More Options.
- In JVM Arguments, change
-Xmx2Gto the amount you want, for example-Xmx4G. Keep the rest of the line as it is. - Click Save and start the game.
Write the number with G and no space. Plain Minecraft is fine with 2 to 4 GB; follow a modpack’s own recommendation, as large packs often ask for 6 to 8 GB. Giving Java nearly all of your computer’s RAM makes things worse, because Windows and other programs need memory too.
On a server
The memory is set in the command that starts the server:
java -Xms1G -Xmx2G -jar server.jar nogui # vanilla java -Xms1G -Xmx2G -jar fabric-server-launch.jar nogui # Fabric
-Xmx: the maximum heap. The main setting.-Xms: the starting heap. Setting it lower or equal to-Xmxis fine.
Change the java line in your start script or service file, then restart the server with the stop command first.
Check that it worked
jcmd $(pgrep -f "^java .*nogui") VM.flags | tr ' ' '\n' | grep HeapSize free -h
On our test server with -Xms1G -Xmx2G, this showed InitialHeapSize=1073741824 and MaxHeapSize=2147483648. A Fabric server with Fabric API, Lithium and Chunky used about 730 MB of RAM at idle, before any player joined. Memory use grows with players, loaded chunks and mods.
How much for a server?
- Leave at least 1 GB for the operating system: on a 4 GB VPS, use at most
-Xmx3G. - A small vanilla server for friends: 2 to 3 GB. Modded servers and more players: more.
java.lang.OutOfMemoryError: Java heap spaceinlogs/latest.logmeans-Xmxis too low. If the whole VPS runs out of memory instead,-Xmxis too high for the server.
Related: install Fabric and where to run a Minecraft server. Need more memory? Our Minecraft VPS plans come in several sizes with DDoS protection.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
