Using Aikar’s Flags for Minecraft

Last modified on 07 November 2024 in Minecraft
  • 8 min read
  • 2735
  • 0
Spartak Itskovich

Spartak Itskovich

Game Content Writer

Aikar's Flags

Minecraft title

This is a set of configurations that affects the process of launching a server, designed to optimize the core of your Minecraft server hosting. Any optimization of the game and the game server positively impacts their operation, so with various programs and functions available, they can be freely used, which will positively influence the gameplay process of your server and its support.

TIP

Don't have your own server yet? Order your Minecraft server right now

How to Use Aikar's Flags?

You need to enter specific command lines (script) into the startup parameters to activate Aikar's Flags. Godlike uses Aikar's flags by default, so to customize the parameters "for yourself," go to the Startup Settings section and to the line Additional Startup Parameters, located on your server's game panel:

startup settings setup

Enter or edit these commands:

-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

CAUTION

Do not use all of your server's RAM for this! When setting Xms and Xmx values, if you have 8 GB of memory, it is better to reduce the Xmx and Xms by about 1000-1500 MB to avoid memory exhaustion or server downtime. We recommend using at least 6-10, depending on your plan. If desired, clarify all questions with our support.

Problems with Usage

If your flags are not working due to using an old or different version of Java, we have a solution. Enter these lines according to your Java version:

Java 8-10

-Xloggc:gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=1M

Java 11+

-Xlog:gc*:logs/gc.log:time,uptime:filecount=5,filesize=1M

Explanation According to the Code and Its Use

-Xms -Xmx: The -Xms parameter sets the initial size of memory that will be allocated when the server starts.
Conversely, the -Xmx parameter sets the maximum amount of memory that the server will consume.
UnlockExperimentalVMOptions A parameter used in settings that allows unlocking options that are in experimental mode. Necessary for some of the parameters listed below.
G1NewSizePercent: If you set G1NewSizePercent to 5%, it means that during the startup of your server, 5% of the total memory allocated for your server's operation will be allocated for new objects. This helps optimize memory usage and garbage management on your server, potentially improving its performance and reducing operational delays.
G1MixedGCLiveThresholdPercent: The parameter you can adjust to determine when the G1 garbage collector should initiate a mixed (Mixed) garbage collection. For example, if G1MixedGCLiveThresholdPercent is set to 65%, it means that mixed garbage collection will be initiated when the volume of live data reaches 65% of the total memory volume. Setting this parameter helps balance the performance and memory usage of your server, as mixed garbage collection can help reduce memory fragmentation and decrease the delays during garbage collection operations. (Suitable for older versions)
MaxTenuringThreshold=1 The MaxTenuringThreshold parameter allows you to determine how many times an object must "survive" the garbage collection process in the young generation before it is moved to the old generation. If MaxTenuringThreshold=1, then objects will be moved to the old generation after their first pass through the young generation. This is important because some objects that "survive" many rounds of garbage collection in the young generation may be long-lived objects that continue to be used on the server. In other words, MaxTenuringThreshold controls how long objects remain in the young generation before moving to the old generation.
SurvivorRatio=32: Each Survivor area is used to store objects that have "survived" one iteration of garbage collection in the young generation. Typically, the young generation is divided into two parts: Survivor1 and Survivor2. The Survivor area to which objects are moved depends on how long they have lived in the young generation. The SurvivorRatio parameter determines the amount of memory allocated to each Survivor area relative to the total size of the young generation. For example, if SurvivorRatio=32, it means each Survivor area occupies 1/32 of the total size of the young generation. Since we have drastically reduced MaxTenuringThreshold, we will drastically reduce the use of Survivor space.
AlwaysPreTouch: When AlwaysPreTouch is set to true, the JVM fills all available memory of the server to ensure instant access to objects. However, it should be noted that using this parameter can lead to an increase in server startup time, especially if the server uses a large amount of memory. This may also require additional system resources. Therefore, the use of this parameter should be considered only when instant access to memory is very important for server performance. AlwaysPreTouch configures and reserves memory at the start of the process, ensuring its continuity and improving efficiency. This improves the speed of access to the operating system's memory. Be sure to use Transparent Huge Pages.
+DisableExplicitGC Using +DisableExplicitGC can be useful in cases where garbage collection is called very frequently or in uncontrolled places, which can lead to unstable server operation or high resource costs. It allows the JVM to decide independently when and how often to perform garbage collection, optimizing it for better performance. However, it is worth remembering that disabling explicit garbage collection calls can lead to the accumulation of garbage in the memory, which may not be removed in time, leading to memory overflow or an increase in the time needed to resolve garbage collection later. Therefore, careful consideration should be given to using this parameter, ensuring adequate memory management on your server.
MaxGCPauseMillis=200 The MaxGCPauseMillis parameter sets the maximum allowable pause time in milliseconds during garbage collection (Garbage Collection). Its goal is to control the pause time allocated for garbage collection operations to avoid unacceptable delays in server operation. When MaxGCPauseMillis is set to a value, such as 200, it means that the JVM will try to keep the pause time during garbage collection at no more than 200 milliseconds. If garbage collection takes longer, the JVM may take additional measures to reduce the pause time, such as distributing garbage collection operations into shorter intervals or using other optimization strategies. However, it should be kept in mind that reducing the pause time during garbage collection can lead to an increase in resources spent on garbage collection itself, so it is important to carefully select the value of MaxGCPauseMillis, ensuring a balance between performance and resource usage.
+ParallelRefProcEnabled: +ParallelRefProcEnabled indicates the enabling of parallel reference processing (Parallel Reference Processing). This can be a parameter that allows Minecraft servers to use more efficient methods for managing memory and resources, which can improve performance and reduce delays in the game. Enabling parallel reference processing can help better manage objects and memory used in the game. This is particularly useful for servers with a large number of players or a large world volume, where efficient resource use is key to smooth operation. However, enabling this parameter can increase the use of CPU resources, so it is recommended to carefully consider its use considering the capabilities and needs of your server.
G1RSetUpdatingPauseTimePercent=5 G1RSetUpdatingPauseTimePercent=5 вказує на те, що відсоток часу зупинки, що витрачається на оновлення RSet (Remembered Set), становить 5% під час використання G1 Garbage Collector (G1 GC).
Використання G1 GC з параметром G1RSetUpdatingPauseTimePercent=5 може допомогти зменшити вплив збірки сміття на продуктивність сервера, контролюючи час зупинки, що витрачається на оновлення RSet. Це може допомогти забезпечити плавну роботу сервера та уникнути неприйнятних затримок для гравців.
G1MixedGCCountTarget=4: Setting G1MixedGCCountTarget=4 means that G1 GC aims to perform four mixed garbage collections before considering this mode of garbage collection to be effective. By default - 8. Because we aim to collect more slowly, using less of the old generation.
G1HeapRegionSize=8M+: G1HeapRegionSize=8M indicates the size of each Heap Region when using the G1 Garbage Collector (G1 GC). A Heap Region is parts of memory into which the JVM divides all available memory during operation with G1 GC. By specifying G1HeapRegionSize=8M, you set that each Heap Region should be approximately 8 megabytes in size. Setting the Heap Region size to 8 megabytes is quite common. This size may be optimal for a balance between performance and manageability of memory, especially with a large number of simultaneously active players and objects in the world.
+PerfDisableSharedMem: +PerfDisableSharedMem indicates that the use of shared memory for real-time profiling (real-time profiling) is disabled. Disabling the +PerfDisableSharedMem parameter can be used to improve server performance, especially in cases where real-time profiling is not needed or not used.

TIP

You can learn about how to increase RAM and other features for your server

Now you know about Aikar's Flags functionality and can use it for your Minecraft server operation; our team is always happy to help you with all questions! Play together with GODLIKE.

Rent Minecraft servers

Godlike Minecraft Server Hosting

Test 3 days

Rate the article on a 5-point scale

Be the first to rate this news!
Find mistake? Select it and press Ctrl + Enter to let us know.
Demo
Game
Panel
×

Report a bug

Error text

Your choice