Java Flags: Fine-Tuning the Engine
Beyond Aikar. Optimizations based on real benchmarks for modern hardware and Java 21+ versions.
Many administrators copy and paste flags from 5 years ago. However, with the arrival of Java 21, Ryzen processor architecture (Zen 3/4/5), and Intel performance cores, the game has changed. This guide is based on BruceTheMoose benchmarks and high-performance standards to minimize stuttering and maximize multi-threaded performance.
The RAM Myth: How much is enough?
The Key Concept
Assigning more RAM is not always better. Too much RAM increases Garbage Collector cleanup times, causing latency spikes. The goal is to keep MSPT (Milliseconds Per Tick) below 50ms.
Hardware vs. Allocation
If your server has 16GB of total RAM, never assign all 16GB to Minecraft. The Operating System and the JVM need 'breathing room'. It's always better to have a fast CPU with 8GB of RAM than a slow CPU with 32GB. Minecraft is primarily single-core.
Reference Guide
- Small (1-10 players): 4GB - 6GB
- Medium (10-40 players): 6GB - 10GB
- Large / Modded (50+ players): 12GB - 16GB (Max recommended)
I. Launch Profiles (Presets)
Not all servers are equal. Choose the profile that best fits your hardware.
1. Modern Standard (Universal / Java 21)
Ideal for most servers on 1.20.x or higher.
java -Xms8G -Xmx8G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -XX:G1MixedGCLiveThresholdPercent=90 -jar paper.jar nogui
2. Extreme Low-Latency Profile (Ryzen / High-End)
Optimized for processors with high L3 cache and competitive servers.
java -Xms12G -Xmx12G -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseTransparentHugePages -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=16M -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1ReservePercent=15 -jar paper.jar nogui
II. The Parameter Dictionary (Technical Breakdown)
Here we explain the "why" of each flag. Configure with knowledge, not faith.
| Parameter | Function | Impact |
|---|---|---|
| -Xms / -Xmx | Defines initial and maximum RAM. | Critical: Must be equal to prevent heap resizing lag. |
| +UseG1GC | Activates G1 Garbage Collector. | Essential: The most stable collector for low-latency servers. |
| +AlwaysPreTouch | Reserves all assigned RAM at startup. | High: Eliminates stuttering caused by on-demand allocation. |
| MaxGCPauseMillis | Target max time the GC can stop the server. | Medium: 200ms is standard. 50ms improves fluidity but strains CPU. |
| G1HeapRegionSize | Size of RAM "regions". | Technical: 8M or 16M is optimal for 8GB-16GB heaps. |
| DisableExplicitGC | Ignores System.gc() calls. | Safety: Prevents poorly optimized plugins from forcing GC. |
III. Hardware-Specific Optimizations
Intel Processors (12th Gen+)
If you use a processor with E-Cores (efficiency cores), make sure Java runs only on P-Cores (performance cores) through CPU affinity in your panel or OS. Tip: The flag -XX:+UseLargePages can give a 5-10% boost if your OS has them configured.
AMD Ryzen Processors
Ryzen benefits enormously from a higher G1NewSizePercent (40%) due to how they manage cache, reducing memory access latency.
IV. Final Recommendations
Never assign more than 16GB to a single Minecraft server, unless you use hundreds of mods. More RAM usually means longer Garbage Collection pauses.
Monitoring:
If something goes wrong, use /spark heapdump to see what is filling your memory.