Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion java/bin/java-dynamic-memory-opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ die () {
# Required env vars validations
[ -z "${MEM_JAVA_PERCENT}" ] && die "Need to set env var MEM_JAVA_PERCENT"

MEM_TOTAL_KB=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
MEM_TOTAL_KB=0

CGROUP_LIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
if [ $CGROUP_LIMIT -ne 9223372036854771712 ] && [ $CGROUP_LIMIT -gt 0 ] ; then
MEM_TOTAL_KB=$CGROUP_LIMIT/1000
else
MEM_TOTAL_KB=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
fi
MEM_JAVA_KB=$((${MEM_TOTAL_KB} * ${MEM_JAVA_PERCENT} / 100))
[ -z "${MEM_JAVA}" ] && export MEM_JAVA="${MEM_JAVA_KB}k"

Expand Down