Skip to content

Instantly share code, notes, and snippets.

@Artuto
Last active November 30, 2021 18:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Artuto/2cf3d419407aee2567f91683682300ad to your computer and use it in GitHub Desktop.
Save Artuto/2cf3d419407aee2567f91683682300ad to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Properly tunes a Minecraft server to run efficiently under the
# OpenJ9 (https://www.eclipse.org/openj9) JVM.
#
# Licensed under the MIT license.
#
## BEGIN CONFIGURATION
# HEAP_SIZE: This is how much heap (in MB) you plan to allocate
# to your server. By default, this is set to 4096MB,
# or 4GB.
#HEAP_SIZE=4096
# JAR_NAME: The name of your server's JAR file. The default is
# "paperclip.jar".
#
# Side note: if you're not using Paper (http://papermc.io),
# then you should really switch.
#JAR_NAME=paperclip.jar
## END CONFIGURATION -- DON'T TOUCH ANYTHING BELOW THIS LINE!
## BEGIN SCRIPT
# Compute the nursery size.
NURSERY_MINIMUM=$(($HEAP_SIZE / 2))
NURSERY_MAXIMUM=$(($HEAP_SIZE * 4 / 5))
# Launch the server.
CMD="java -Xms${HEAP_SIZE}M -Xmx${HEAP_SIZE}M -Xmns${NURSERY_MINIMUM}M -Xmnx${NURSERY_MAXIMUM}M -Xgc:concurrentScavenge -Xgc:dnssExpectedTimeRatioMaximum=3 -Xgc:scvNoAdaptiveTenure -Xdisableexplicitgc -Xtune:virtualized -jar ${JAR_NAME}"
echo "launching server with command line: ${CMD}"
${CMD}
## END SCRIPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment