Skip to content

Commit 5ae268a

Browse files
committed
Set ES JVM HEAP Xms equal to Xmx
Closes #383
1 parent e231410 commit 5ae268a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

elasticsearch/run.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if [[ "${INSTANCE_RAM:-}" =~ $regex ]]; then
3939
fi
4040

4141
#determine if req is less then max recommended by ES
42-
echo "Comparing the specificed RAM to the maximum recommended for ElasticSearch..."
42+
echo "Comparing the specified RAM to the maximum recommended for Elasticsearch..."
4343
if [ ${MAX_ES_MEMORY_BYTES} -lt ${num} ]; then
4444
((num = ${MAX_ES_MEMORY_BYTES}))
4545
echo "Downgrading the INSTANCE_RAM to $(($num / BYTES_PER_MEG))m because ${INSTANCE_RAM} will result in a larger heap then recommended."
@@ -55,15 +55,18 @@ if [[ "${INSTANCE_RAM:-}" =~ $regex ]]; then
5555
echo "Setting the maximum allowable RAM to $(($num / BYTES_PER_MEG))m which is the largest amount available"
5656
fi
5757
else
58-
echo "Unable to determine the maximum allowable RAM for this host in order to configure ElasticSearch"
58+
echo "Unable to determine the maximum allowable RAM for this host in order to configure Elasticsearch"
5959
exit 1
6060
fi
6161

6262
if [[ $num -lt $MIN_ES_MEMORY_BYTES ]]; then
6363
echo "A minimum of $(($MIN_ES_MEMORY_BYTES/$BYTES_PER_MEG))m is required but only $(($num/$BYTES_PER_MEG))m is available or was specified"
6464
exit 1
6565
fi
66-
export ES_JAVA_OPTS="${ES_JAVA_OPTS:-} -Xms128M -Xmx$(($num/2/BYTES_PER_MEG))m"
66+
67+
# Set JVM HEAP size to half of available space
68+
num=$(($num/2/BYTES_PER_MEG))
69+
export ES_JAVA_OPTS="${ES_JAVA_OPTS:-} -Xms${num}m -Xmx${num}m"
6770
echo "ES_JAVA_OPTS: '${ES_JAVA_OPTS}'"
6871
else
6972
echo "INSTANCE_RAM env var is invalid: ${INSTANCE_RAM:-}"

0 commit comments

Comments
 (0)