Last active
April 11, 2019 09:47
-
-
Save zoran/5ef05b2674a1acc1fc66940286d0fdfb to your computer and use it in GitHub Desktop.
Return reasonable JVM options
This file contains 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 | |
CGROUPS_MEM=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) | |
MEMINFO_MEM=$(($(awk '/MemTotal/ {print $2}' /proc/meminfo)*1024)) | |
MEM=$(($MEMINFO_MEM>$CGROUPS_MEM?$CGROUPS_MEM:$MEMINFO_MEM)) | |
JVM_HEAP_RATIO=${JVM_HEAP_RATIO:-0.5} | |
XMX=$(awk '{printf("%d",$1*$2/1024^2)}' <<<" ${MEM} ${JVM_HEAP_RATIO} ") | |
echo "-Xmx${XMX}m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment