From 43809211d41c1ea0ee73fd5d49fb41003149d919 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 6 Feb 2012 22:09:32 +0200 Subject: [PATCH] bin: elasticsearch script to support ES_HEAP_SIZE to easily set the heap size to a single value (min and max) and ES_HEAP_NEWSIZE to optionally set the new gen, closes #1671. --- bin/elasticsearch.bat | 10 ++++++++++ bin/elasticsearch.in.sh | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/bin/elasticsearch.bat b/bin/elasticsearch.bat index 00388e7d0aa..dfa4e7c093d 100644 --- a/bin/elasticsearch.bat +++ b/bin/elasticsearch.bat @@ -18,7 +18,17 @@ if "%ES_MAX_MEM%" == "" ( set ES_MAX_MEM=1g ) +if NOT "%ES_HEAP_SIZE%" == "" ( +set ES_MIN_MEM=%ES_HEAP_SIZE% +set ES_MAX_MEM=%ES_HEAP_SIZE% +) + set JAVA_OPTS=%JAVA_OPTS% -Xms%ES_MIN_MEM% -Xmx%ES_MAX_MEM% + +if NOT "%ES_HEAP_NEWSIZE%" == "" ( +set JAVA_OPTS=%JAVA_OPTS% -Xmn%ES_HEAP_NEWSIZE% +) + set JAVA_OPTS=%JAVA_OPTS% -Xss128k REM Enable aggressive optimizations in the JVM diff --git a/bin/elasticsearch.in.sh b/bin/elasticsearch.in.sh index 7ee2c9b039f..c923d9c1424 100644 --- a/bin/elasticsearch.in.sh +++ b/bin/elasticsearch.in.sh @@ -6,6 +6,10 @@ fi if [ "x$ES_MAX_MEM" = "x" ]; then ES_MAX_MEM=1g fi +if [ "x$ES_HEAP_SIZE" != "x" ]; then + ES_MIN_MEM=$ES_HEAP_SIZE + ES_MAX_MEM=$ES_HEAP_SIZE +fi # min and max heap sizes should be set to the same value to avoid # stop-the-world GC pauses during resize, and so that we can lock the @@ -14,6 +18,11 @@ fi JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}" JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}" +# new generation +if [ "x$ES_HEAP_NEWSIZE" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -Xmn${ES_HEAP_NEWSIZE}" +fi + # reduce the per-thread stack size JAVA_OPTS="$JAVA_OPTS -Xss128k"