Skip to content

Commit

Permalink
use /sys/fs/cgroup/memory.max as maximum memory metric instead of the
Browse files Browse the repository at this point in the history
output of the free command in case RaspberryMatic is used in a memory
limiting container environment so that HMIPServer won't consume and
overly amount of host memory.
  • Loading branch information
jens-maus committed Dec 3, 2024
1 parent ea55154 commit 5c0cddb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion buildroot-external/overlay/base/etc/init.d/S62HMServer
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ start() {

# calculate the maximum used heap size (-Xmx) depending on the
# total amount of RAM we have (use max. 25%) - use multiple of 128MB
MAXHEAP=$(free -m | grep Mem: | awk '{print int($2*0.25/128)*128}')
if [[ -e /sys/fs/cgroup/memory.max ]]; then
MAXHEAP=$(cat /sys/fs/cgroup/memory.max | awk '{print int(($1/1024/1024)*0.25/128)*128}')
else
MAXHEAP=$(/usr/bin/free -m | grep Mem: | awk '{print int($2*0.25/128)*128}')
fi
if [[ -n "${MAXHEAP}" ]] && [[ "${MAXHEAP}" -gt 128 ]]; then
JAVAOPT="-Xmx${MAXHEAP}m ${JAVAOPT}"
else
Expand Down

0 comments on commit 5c0cddb

Please sign in to comment.