Minecraft Server Startup Codes and RAM Optimization (Aikar's Flags)
No matter how much RAM you have on Minecraft servers, if Java's memory cleaning logic (Garbage Collection) is not configured correctly, the server will experience sudden freezes (Spike Lag) every few minutes. You start your serverstart.batorbaslat.batOptimizing the file solves these freezes radically. world famous Aikar's Flags You can find the correct initialization code with parameters in this guide.
Step 1: Harms of Incorrect Initialization Code
Most server owners just run their serverjava -Xmx8G -Xms8G -jar server.jarIt starts with the command. This code completely releases Java. Java fills the memory and then stops the entire server for a split second to clear it (GC lag). Players feel this as "Throwing back or getting stuck".
Step 2: Optimized Aikar's Launch Codes
your server start.bat Right-click the file, edit it, delete all the codes in it and paste the following updated codes according to the amount of RAM you have assigned to your server:
For Servers Allocating 8 GB RAM:
@echo off java -Xmx8G -Xms8G -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:InitiatingHeapProfilingPercent=45 -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 server.jar nogui pause
Note: If you are going to give 12 GB RAM to your server, the code at the beginning-Xmx8G -Xms8Gareas-Xmx12G -Xms12GYou should change it to . Alsoserver.jarSynchronize the part that says with the name of your main jar file (Ex: paper.jar).
Step 3: Advantages of the Code
- G1GC Activation: It activates Java's most stable and Minecraft-compatible garbage collection module.
- Instant Memory Clear: It cleans the RAM in small pieces in the background when the server is idle, preventing the server from freezing.
- Processor Priority: It allows Java to use processor cores more balancedly.
This article is specially prepared for PvPServer.