Minecraft Java Cheatsheet

Go back

This is less a guide or in-depth explanation and more a "here's the values you need to copy-paste". If you're here, I probably pointed you to this website in which case just do as I say, will you?

As always, remember I'm just a guy on the internet. I have not (yet) attained the status of "Java Performance Wizard", so take what I say with a giant grain of salt.

Versions and Distributions

Use Java 25. "But my modpack is made for Java 21!". Yeah and I don't care, use Java 25 It'll probably work anyways. If whatever you're running can't support Java 25 it's probably time to update anyways.

Also please use Adoptium Temurin as your Java distribution. It is the gold standard of JDKs and highly recommended by basically everyone.

General Recommendations

Allocate 6-10 GB of heap space for a typical Vanilla server or client. Don't allocate less than 4 GB or more than 12 GB unless you know what you're doing.

Always have -Xms equal to -Xmx. This prevents lag spikes caused by Java dynamically taking and giving memory back to the operating system.

Flags

Very Small Heaps (0-2 GB)

Reconsider your life choices. Shenanigans are certainly possible though.

Small Heaps (2-6 GB)

Use: -XX:+UseCompactObjectHeaders -XX:+UseStringDeduplication -XX:+AlwaysPreTouch -XX:+PerfDisableSharedMem -XX:G1HeapRegionSize=8M

Medium to Large Heaps (6-24 GB)

Use: -XX:+UseZGC -XX:-ZProactive -XX:+UseCompactObjectHeaders -XX:+UseStringDeduplication -XX:+AlwaysPreTouch -XX:+PerfDisableSharedMem

If your cpu is older than the AMD Ryzen 3000 series or the Intel Core 10000 series don't allocate more than 12 GB and use the flags for Small Heaps.

Very Large Heaps (24+ GB)

Allocating more than 24 GB is most likely a bad idea and very unnecessary but if you must use the same flags as on Medium to Large Heaps and follow the applicable Advanced Optimizations listed below.

Advanced Optimizations

Use at your own risk!