diff options
Diffstat (limited to 'container-disc/src/main/sh/vespa-start-container-daemon.sh')
-rwxr-xr-x | container-disc/src/main/sh/vespa-start-container-daemon.sh | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/container-disc/src/main/sh/vespa-start-container-daemon.sh b/container-disc/src/main/sh/vespa-start-container-daemon.sh index 3afefd6f86d..ec632a9c0c4 100755 --- a/container-disc/src/main/sh/vespa-start-container-daemon.sh +++ b/container-disc/src/main/sh/vespa-start-container-daemon.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #set -x @@ -65,14 +65,21 @@ configure_memory() { consider_fallback jvm_baseMaxDirectMemorySize 75 consider_fallback jvm_directMemorySizeCache 0 - if (( jvm_heapSizeAsPercentageOfPhysicalMemory > 0 && jvm_heapSizeAsPercentageOfPhysicalMemory < 100 )); then - available=`free -m | grep Mem | tr -s ' ' | cut -f2 -d' '` - jvm_heapsize=$[available * jvm_heapSizeAsPercentageOfPhysicalMemory / 100] + # Update jvm_heapsize only if percentage is explicitly set (default is 0). + if ((jvm_heapSizeAsPercentageOfPhysicalMemory > 0)); then + if ((TOTAL_MEMORY_MB > 0)); then + available="$TOTAL_MEMORY_MB" + else + available=`free -m | grep Mem | tr -s ' ' | cut -f2 -d' '` + fi + + jvm_heapsize=$((available * jvm_heapSizeAsPercentageOfPhysicalMemory / 100)) if (( jvm_heapsize < 1024 )); then jvm_heapsize=1024 fi fi - maxDirectMemorySize=$(( ${jvm_baseMaxDirectMemorySize} + ${jvm_heapsize}/8 + ${jvm_directMemorySizeCache} )) + + maxDirectMemorySize=$(( jvm_baseMaxDirectMemorySize + jvm_heapsize / 8 + jvm_directMemorySizeCache )) memory_options="-Xms${jvm_heapsize}m -Xmx${jvm_heapsize}m" memory_options="${memory_options} -XX:ThreadStackSize=${jvm_stacksize}" |