java -Xms4G -Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -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:+UseStringDeduplication -Daikars.new.flags=true -jar server.jar --nogui
Note: These flags are based on Aikar's recommended flags for Minecraft servers. Adjust RAM allocation based on your server's needs - don't allocate more than you need.
Understanding Startup Flags
Startup flags (also called JVM arguments) configure how Java runs your Minecraft server. The right flags can significantly improve performance by optimizing garbage collection and memory management.
Key Concepts
Memory Allocation (-Xms and -Xmx)
- -Xms sets the initial heap size
- -Xmx sets the maximum heap size
- Setting both to the same value prevents Java from resizing the heap during runtime
How much RAM?
For most servers, 4-8GB is sufficient. Allocating more RAM than needed can actually hurt performance due to longer garbage collection pauses. Start low and increase only if needed.
Garbage Collection
Minecraft servers generate a lot of temporary objects that need to be cleaned up. The garbage collector (GC) handles this, but it can cause lag spikes if not configured properly.
G1GC (Garbage-First Garbage Collector) is the recommended collector for most servers. It:
- Targets low pause times
- Works well with large heaps
- Is stable and well-tested
ZGC (Z Garbage Collector) is an experimental option for Java 17+ that offers:
- Extremely low pause times (sub-millisecond)
- Higher CPU usage
- Best for servers where consistent tick times are critical
Aikar's Flags
The flags generated by this tool are based on Aikar's flags, which are widely considered the gold standard for Minecraft server optimization. They've been tested on large networks serving thousands of players.
Usage Instructions
- Select your RAM - Choose how much memory to allocate
- Choose Java version - Newer versions support more optimizations
- Select server type - Different servers may benefit from slight variations
- Toggle experimental - Enable ZGC if you want cutting-edge performance
- Copy the flags - Use them in your start script
Creating Your Start Script
Windows (start.bat)
@echo off
[paste your generated flags here]
pause
Linux/Mac (start.sh)
#!/bin/bash
[paste your generated flags here]
Make the script executable on Linux/Mac:
chmod +x start.sh
Troubleshooting
Out of Memory Errors
If you see OutOfMemoryError, try increasing your RAM allocation. Make sure your system has enough free RAM for the OS and other processes.
High CPU Usage
If you enabled ZGC and notice high CPU usage, switch back to G1GC. ZGC trades CPU cycles for lower pause times.