Skip to content

Instantly share code, notes, and snippets.

@astei
Last active May 1, 2019 17:37
Show Gist options
  • Save astei/f6fcf727e060326f917240f4104d0d05 to your computer and use it in GitHub Desktop.
Save astei/f6fcf727e060326f917240f4104d0d05 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 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