A guide to using Aikar’s flags to optimize the performance of your Minecraft server.
/spark health
for accurate memory usage.
{SERVER_MEMORY}
with the amount of RAM you want to
allocate to your server.-Xmx
: Sets the maximum amount of memory that the JVM can use. This can help
prevent the server from crashing due to out-of-memory errors.-Xms
: Sets the initial amount of memory that the JVM uses when starting up.
Aikar’s flags set this to the same value as -Xmx
, because unused memory is
wasted memory.-XX:+UseG1GC
: Enables the Garbage-First (G1) Garbage Collector, which is a
low-latency garbage collector that adaptively chooses how much memory to give
to each region to optimize pause time-XX:+ParallelRefProcEnabled
: Enables parallel reference processing and lets GC use multiple threads for weak reference checking.-XX:MaxGCPauseMillis
: Sets the maximum amount of time that the JVM can spend
on garbage collection.-XX:+UnlockExperimentalVMOptions
: Unlocks experimental JVM options which are needed for Aikar’s flags.-XX:+DisableExplicitGC
: Disables explicit garbage collection, which prevents bad plugin code from affecting your server.-XX:+AlwaysPreTouch
: Enables pre-touching, which will preallocate all the memory at process start.-XX:G1NewSizePercent
: Sets the percentage of the heap that is used for new
objects.-XX:G1MaxNewSizePercent
: Sets the maximum percentage of the heap that is
used for new objects.-XX:G1HeapRegionSize
: Sets the size of the G1 heap region.-XX:G1ReservePercent
: Sets the percentage of the heap that is reserved for
G1.-XX:G1HeapWastePercent
: Sets the percentage of the heap that is wasted.-XX:G1MixedGCCountTarget
: Sets the target number of mixed garbage
collections.-XX:InitiatingHeapOccupancyPercent
: Sets the percentage of the heap that is
used before a mixed garbage collection is triggered.-XX:G1MixedGCLiveThresholdPercent
: Sets the percentage of live objects that
are required for a mixed garbage collection to be triggered.-XX:G1RSetUpdatingPauseTimePercent
: Sets the percentage of time that is
spent on updating the remembered set.-XX:SurvivorRatio
: Sets the ratio of the survivor space to the eden space.-XX:+PerfDisableSharedMem
: Disables shared memory.-XX:MaxTenuringThreshold
: Sets the maximum tenuring threshold.server.log
file in the logs folder of your server for any error messages.
If these flags have helped your server significantly, consider donating to
Aikar to support his work.