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

  1. Open the launcher, select Minecraft: Java Edition and click the Installations tab.
  2. Hover over the installation you use (for example your Fabric one), click the three dots and choose Edit.
  3. Click More Options.
  4. In JVM Arguments, change -Xmx2G to the amount you want, for example -Xmx4G. Keep the rest of the line as it is.
  5. 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 -Xmx is 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 space in logs/latest.log means -Xmx is too low. If the whole VPS runs out of memory instead, -Xmx is 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

Was this answer helpful? 0 Users Found This Useful (0 Votes)