Skip to content

Instantly share code, notes, and snippets.

@mikroskeem
Forked from astei/something.go
Created March 10, 2019 11:14
Show Gist options
  • Save mikroskeem/c87c739d54dbd55a41dbb590d59be07f to your computer and use it in GitHub Desktop.
Save mikroskeem/c87c739d54dbd55a41dbb590d59be07f to your computer and use it in GitHub Desktop.
func getFlags(desiredHeap int64) string {
asKb := desiredHeap / units.KiB
// the following is specific to OpenJ9 and is based on Aikar's flags:
// https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
// The equivalent of -XX:G1NewSizePercent/-XX:G1MaxNewSizePercent in OpenJ9's gencon policy is -Xmns/-Xmnx.
// We have to manually compute these values ourselves. By default, the gencon policy assumes 25% of Xms, which is
// simply not sufficient for Minecraft (and Aikar can tell you).
xmns := asKb / 2
xmnx := asKb * 4 / 5
memFlags := fmt.Sprintf("-Xms%dk -Xmx%dk -Xmns%dk -Xmnx%dk", asKb, asKb, xmns, xmnx)
return command := fmt.Sprintf("java -Xtune:virtualized -XX:+UseContainerSupport -Xgc:dnssExpectedTimeRatioMaximum=3 -Xgc:scvNoAdaptiveTenure %s -jar paper.jar", memoryFlags)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment