# Invalid initial heap size on ES7 for Windows

**URL:** <https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781>\
**Category:** Elasticsearch\
**Created:** [October 21, 2020, 7:11am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781 "2020-10-21T07:11:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbakti7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbakti7/32/42250_2.png) [@dbakti7](https://discuss.elastic.co/u/dbakti7)\
**Post date:** [October 21, 2020, 7:11am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781/1 "2020-10-21T07:11:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 21, 2020, 8:03am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781/2 "2020-10-21T08:03:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dbakti7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbakti7/32/42250_2.png) [@dbakti7](https://discuss.elastic.co/u/dbakti7)\
**Post date:** [October 21, 2020, 8:20am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781/3 "2020-10-21T08:20:56Z")

</div>

@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...

---

<div class="post-metadata">

**Author:** ![dbakti7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbakti7/32/42250_2.png) [@dbakti7](https://discuss.elastic.co/u/dbakti7)\
**Post date:** [October 21, 2020, 9:38am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781/4 "2020-10-21T09:38:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 18, 2020, 9:39am UTC](https://discuss.elastic.co/t/invalid-initial-heap-size-on-es7-for-windows/252781/5 "2020-11-18T09:39:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
