Startup parameters
These are special options that allow you to optimize the server startup and its further performance.
Please note that the arguments must be selected individually based on the server hardware and the Java version.
Let’s start with a small example:
java -jar server.jar
Â
This is the most basic script to start the server core, with no additional arguments specified.
Now to the parameters themselves
-jar — this argument specifies the type of the Java file being launched.
name.jar — the name of the file to be launched.
nogui — starts the server without a graphical interface, since we simply do not need it.
Core flags
-xincgc — enables a "garbage collector" that periodically frees unused RAM. The specific collector type is selected automatically depending on the Java version.
-server — enables the server Java mode, where support for experimental flags is enabled by default. It also speeds up class compilation, which improves performance, but increases server startup time (supported only on 64-bit systems).
Allocating RAM
-Xmx0000M — the maximum amount of memory that can be allocated to the server.
-Xms0000M — the minimum amount of memory allocated to the server.
-Xmn0000M — the amount of memory allocated for temporary (young generation) objects.
-XX:MaxPermSize=0000M — the amount of memory for the PermGen Space (does not work on Java 8).
-XX:SharedReadOnlySize=0000M — the amount of memory for the read-only area in PermGen.
Garbage collectors
-XX:+UseSerialGC — enables a garbage collector that runs in a single thread.
-XX:+UseConcMarkSweepGC — enables a garbage collector that uses the power of multiple CPU cores.
-XX:ConcGCThreads=2 — the number of threads allocated to the garbage collector.
-XX:+UseG1GC — enables the new garbage collector that splits the heap into regions and, using multiple cores, collects unused memory across all regions.
-XX:G1HeapRegionSize=32 — the amount of RAM allocated for each region.
-XX:AutoGCSelectPauseMillis=2500 — the time in milliseconds between calls to the automatically selected garbage collector.
-XX:MaxGCPauseMillis=1000 — the pause duration in milliseconds between calls to a specific garbage collector. For G1GC it acts as the maximum allowed pause.
-XX:SurvivorRatio=8 — the ratio that defines the size of the survivor spaces (the smaller the number, the more space). More space allows newly created objects to live longer before being collected.
-XX:TargetSurvivorRatio=90 — the percentage of space reserved for survivor objects, which allows more unused objects to be cleaned up during garbage collection.
-XX:+UseBiasedLocking — speeds up object synchronization on multi-core CPUs.
-XX:+UseFastAccessorMethods — uses optimized versions of accessor method calls.
-XX:+UseFastEmptyMethods — excludes empty methods from compilation.
XX:+UseCompressedOops — reduces the size of pointers, object headers and internal offsets. Depending on the code, this can save 20–60% of RAM.
As a result, we get the following sample script to start the server:
Â
java -Xincgc -Xms512M -Xmx4G -XX:MaxPermSize=128M -XX:SharedReadOnlySize=30M -XX:+UseConcMarkSweepGC -XX:+UseBiasedLocking -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -jar server.jar nogui








