Skip to content

Commit 11b15bc

Browse files
committed
intro veryhighmem setting with no custom -Xms and -Xmx for boxes with >= 3 GB
Signed-off-by: Markus Storm <markus.storm@gmx.net>
1 parent 82878cc commit 11b15bc

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

functions/helpers.bash

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ has_lowmem() {
439439
## Returns 0 / true if device has more than 1500MB of total memory
440440
## Returns 1 / false if device has less than 1500MB of total memory
441441
##
442-
## has_hasmem()
442+
## has_highmem()
443443
##
444444
has_highmem() {
445445
local totalMemory
@@ -450,6 +450,20 @@ has_highmem() {
450450
if [[ $totalMemory -gt 1500000 ]]; then return 0; else return 1; fi
451451
}
452452

453+
## Returns 0 / true if device has more than 3000MB of total memory
454+
## Returns 1 / false if device has less than 3000MB of total memory
455+
##
456+
## has_veryhighmem()
457+
##
458+
has_veryhighmem() {
459+
local totalMemory
460+
461+
totalMemory="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"
462+
463+
if [[ -z $totalMemory ]]; then return 1; fi # assume that device does not have very high memory
464+
if [[ $totalMemory -gt 3000000 ]]; then return 0; else return 1; fi
465+
}
466+
453467
## Attempt to update apt package lists 10 times
454468
## unless 'apt-get update' evaulates to 0.
455469
## Sleeps for 1 second between each attempt.

functions/openhab.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,11 @@ openhab_misc() {
231231
if has_lowmem; then
232232
if cond_redirect sed -i -e 's|^EXTRA_JAVA_OPTS=.*$|EXTRA_JAVA_OPTS="-Xms16m -Xmx256m -Xss1024k -XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true"|g' /etc/default/openhab; then echo "OK"; else echo "FAILED"; return 1; fi
233233
elif has_highmem; then
234-
if cond_redirect sed -i -e 's|^EXTRA_JAVA_OPTS=.*$|EXTRA_JAVA_OPTS="-Xms192m -Xmx768m -XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true"|g' /etc/default/openhab; then echo "OK"; else echo "FAILED"; return 1; fi
234+
if has_veryhighmem; then
235+
if cond_redirect sed -i -e 's|^EXTRA_JAVA_OPTS=.*$|EXTRA_JAVA_OPTS="-XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true"|g' /etc/default/openhab; then echo "OK"; else echo "FAILED"; return 1; fi
236+
else
237+
if cond_redirect sed -i -e 's|^EXTRA_JAVA_OPTS=.*$|EXTRA_JAVA_OPTS="-Xms192m -Xmx768m -XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true"|g' /etc/default/openhab; then echo "OK"; else echo "FAILED"; return 1; fi
238+
fi
235239
else
236240
if cond_redirect sed -i -e 's|^EXTRA_JAVA_OPTS=.*$|EXTRA_JAVA_OPTS="-Xms192m -Xmx384m -XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+ExitOnOutOfMemoryError -Dxtext.qn.interning=true"|g' /etc/default/openhab; then echo "OK"; else echo "FAILED"; return 1; fi
237241
fi

0 commit comments

Comments
 (0)