Skip to content

Commit 1c384fb

Browse files
authored
Add default CLI JVM options (#44545)
This commit adds some default CLI JVM options to control the heap size and the garbage collector used for the CLI tools. We do this because otherwise the JVM will default to large initial and max heap sizes based on the RAM visible to the JVM (which could be all the physical RAM on the machine if not run in a container-aware JVM). This commit therefore sets the initial heap size to 4m, the max heap size to 64m, the garbage collector to the serial collector, and leaves this user-configurable by honoring ES_JAVA_OPTS last.
1 parent 23828cf commit 1c384fb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

distribution/src/bin/elasticsearch-cli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ do
1616
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/$additional_classpath_directory/*"
1717
done
1818

19+
# use a small heap size for the CLI tools, and thus the serial collector to
20+
# avoid stealing many CPU cycles; a user can override by setting ES_JAVA_OPTS
21+
ES_JAVA_OPTS="-Xms4m -Xmx64m -XX:+UseSerialGC ${ES_JAVA_OPTS}"
22+
1923
exec \
2024
"$JAVA" \
2125
$ES_JAVA_OPTS \

distribution/src/bin/elasticsearch-cli.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ if defined ES_ADDITIONAL_CLASSPATH_DIRECTORIES (
1212
)
1313
)
1414

15+
rem use a small heap size for the CLI tools, and thus the serial collector to
16+
rem avoid stealing many CPU cycles; a user can override by setting ES_JAVA_OPTS
17+
set ES_JAVA_OPTS=-Xms4m -Xmx64m -XX:+UseSerialGC %ES_JAVA_OPTS%
18+
1519
%JAVA% ^
1620
%ES_JAVA_OPTS% ^
1721
-Des.path.home="%ES_HOME%" ^

0 commit comments

Comments
 (0)