Created
December 17, 2016 17:49
-
-
Save ajbrown/70dd0b4405e353a5ed13175ba94d6c0e to your computer and use it in GitHub Desktop.
Dynamically determine the Java heap based on the total memory of the VM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
totalMemKB=$(awk '/MemTotal:/ { print $2 }' /proc/meminfo) | |
usagePercent=70 | |
let heapMB=$totalMemKB*$usagePercent/100/1024 | |
JAV_OPTS="$JAVA_OPTS -Xmx${heapMB}M -Xms${heapMB}M" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment