Editing
Tutorials/Setting up a server
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Java options === Java options should be added between the {{code|java}} and the {{code|-jar}} on the command line, or in your startup script. ; Memory limits : The most important thing for a ''Minecraft'' server is memory to run with. <code>-Xmx</code> defines how much memory it is allowed to use. {{code|-Xmx2G}} (2 gigabytes) is more than enough for a home server with 5 players on default [[simulation distance]] (5×21<sup>2</sup> = 2205 chunks simulated), but do scale it up by your actual settings. Setting the value too low causes frequent GC stops. Making it too high can make GC too long on Java 8 – a version you should not be using in the first place. : {{code|-Xms}} (the initial memory size) is the next biggest knob, but ''only'' affects startup performance. If your server also runs things other than ''Minecraft'', set it to 1/4 of the maximum size (so for our case, {{code|-Xms512M}}) for a good balance: the JVM will be allowed to return some memory to the OS when it's not needed. (The return algorithm is ''very'' conservative, so it has very minimal effect on long-term performance.) If your server is fully dedicated to ''Minecraft'', feel free to go higher: making it equal to the maximum size disables heap scaling and gives maximum startup speed. : A "soft max heap size" ({{code|1=-XX:SoftMaxHeapSize=1G}}) is available for some versions of JRE. The JRE will try to only use that much memory, but will go over to a maximum of <code>-Xmx</code> if necessary. If you are running many things on your server, this may be useful. ; GC : The default GC on Java 9+ used by modern ''Minecraft'' is G1GC (Java 8 also has it, but it is off by default). The flags used by the official launcher {{code|1=-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M}} works reasonably well, though of course [https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks#server-g1gc better flags (brucethemoose)] exist. ([https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/ Aikar's famous flags] are good, but not optimal.) : On Java 14+, ZGC is available. This GC is almost lag-free with millisecond-level pauses. Delete all GC-related flags and simply use {{code|-XX:+UnlockExperimentalVMOptions -XX:+UseZGC}}. Tuning flags other than {{code|-Xmx}} are [https://docs.oracle.com/en/java/javase/17/gctuning/z-garbage-collector.html#GUID-9957D441-A99A-4CF5-9522-393E6DE7D898 a lot less important] compared to in GCs (the default is quite good), although {{code|1=-XX:-ZProactive}} is worth a try if you want to trade memory for lag. ; VM : On [https://stackoverflow.com/questions/31078803/usage-of-d32-and-d64-while-launching-java Solaris], use <code>-d64</code> to tell the JVM to use your 64-bit processor properly. Since nobody uses Solaris, this is irrelevant. : Calculations may be made faster with GraalVM, benefiting operations such as chunk generation. A basic version is bundled in the common "HotSpot" Java 9–15, but it was later removed due to maintenance burden. Now you need to download it separately: use [https://github.com/brucethemoose/Minecraft-Performance-Flags-Benchmarks#graalvm-enterprise-edition instructions from brucethemoose]. To sum up, a reasonable flag combination can be as simple as {{code|1=-Xmx4G -Xms1G -XX:SoftMaxHeapSize=3G -XX:+UnlockExperimentalVMOptions -XX:+UseZGC}}. That is it. There are bits that you can squeeze from complicated flags, but you would get much more from [[Mods|modified server software]]. In fact, all serious discussions (e.g. Aikar and brucethemoose) of server performance assume some degree of modding.
Summary:
Please note that all contributions to Kiiw may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Kiiw:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information