Invalid initial heap size on ES7 for Windows

We are trying to install ES7 as windows service with

elasticsearch-service.bat install

We are setting ES_JAVA_OPTS via environment variable with -Xms4g -Xmx4g
But we are getting the following error:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Invalid initial heap size: -Xms4g;-Xmx4g
at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:126)
at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88)
at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:137)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:95)

I see that in the bat script we have the following line:

if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%

This line seems to replace space with semicolon character.

May I know what is the right way to set Xms and Xms via env var? space delimited values do not seem to work with this script.

PS: tried on ES7.9.2

Hey,

the error message states something than what you have ES_JAVA_OPTS set to. The error message seems to read ES_JAVA_OPTS as -Xms4g;-Xmx4g - the semicolon in the middle should be a whitespace.

Can you check if that semicolon has been set somewhere accidentally?

--Alex

@spinscale

D:\ES7_test\elasticsearch-7.9.2\bin>echo %ES_JAVA_OPTS%
-Xms4g -Xmx4g

D:\ES7_test\elasticsearch-7.9.2\bin>elasticsearch-service.bat install
Installing service : "elasticsearch-service-x64"
Using JAVA_HOME (64-bit): ""D:\ES7_test\elasticsearch-7.9.2\jdk""
Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
output:

error:
Invalid initial heap size: -Xms4g;-Xmx4g
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:126)
at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88)
at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:137)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:95)

It's set correctly with space-delimiter in env variable
please refer to my original post, it seems like elasticsearch-service.bat script itself is changing space to semicolon.. not sure if it's a bug on the script or I am missing something here...

I tried on major releases for ES7, i.e. ES7.0.0, ES7.1.0, ES7.2.0, ..., ES7.7.0
elasticsearch-service.bat install with -Xms4g -Xmx4g set on ES_JAVA_OPTS env var only works on ES7.0.0 and ES7.1.0
other version throws the error.
is it some kind of regress?