Aikar’s Flags are startup flags (CLI options) designed to improve performance and optimize Minecraft servers.

Technical explanation: Command-line options for the JVM implementations like OpenJDK and OpenJ9. These flags are designed to improve performance of the JVM’s G1GC garbage collector, this enhancing the performance for Minecraft servers.

All Minecraft server lineups from BerryByte come equipped with Aikar’s flags by default.

Note: Aikar’s Flags allocates all available memory to the server (unused memory is wasted memory) which may make the server appear to be using 100% RAM at all times. This is usually not the case.

To view actual usage for servers running Aikar’s Flags, install the Spark plugin and run the command /spark health for accurate memory usage.

Setting up the flags

Setting up Aikar’s Flags for your server is a very simple process, simply update the parameters of the command that you use to start up your server with the flags listed below.

Remember to replace {SERVER_MEMORY} with the amount of RAM you want to allocate to your server.

Less than 12GB of RAM

JVM Flags
java -Xms{SERVER_MEMORY}M -Xmx{SERVER_MEMORY}M -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui

12GB of RAM or more

JVM Flags
java -Xms{SERVER_MEMORY}M -Xmx{SERVER_MEMORY}M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=20 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar --nogui

Breakdown

If you’re running on a shared hosting (one bulky machine runs multiple Minecraft servers) with strict resource allocation (e.g. Docker containers; this applies for BerryByte’s Minecraft lineup), it is recommended to leave out roughly 1GB of RAM for the JVM’s overhead (this is automatically done at BerryByte).

  • -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.
This flag is removed by default on BerryByte servers, and if you are running the Pterodactyl panel, you should remove this flag too. This flag pre-allocates all memory to the process on startup, starving and freezing/crashing the docker container. If not, you can ignore this warning.
  • -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.

This is only a quick recap, you should give Aikar’s blog a read if you’re interested on how these really work.

It is important to carefully consider the values you use for each startup flag, as setting them too high or too low can have negative impacts on the performance of the server. If you are having trouble using Aikar’s flags, check the server.log file in the logs folder of your server for any error messages.

If you continue to experience issues with the flags, feel free to ask for help on our Discord server. If these flags have helped your server significantly, consider donating to Aikar to support his work.