# Default JAVA\_OPTS in elasticsearch.in.sh

**URL:** <https://discuss.elastic.co/t/default-java-opts-in-elasticsearch-in-sh/37095>\
**Category:** Elasticsearch\
**Created:** [December 14, 2015, 7:28am UTC](https://discuss.elastic.co/t/default-java-opts-in-elasticsearch-in-sh/37095 "2015-12-14T07:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://discuss.elastic.co/u/aman)\
**Post date:** [December 14, 2015, 7:28am UTC](https://discuss.elastic.co/t/default-java-opts-in-elasticsearch-in-sh/37095/1 "2015-12-14T07:28:12Z")

</div>

I tried opening [[ the ticket with `elasticsearch-puppet` but was sent here instead:

> <https://github.com/elastic/puppet-elasticsearch/issues/512>

`elasticsearch.in.sh` (`/usr/share/elasticsearch/bin/elasticsearch.in.sh` on Ubuntu 12.04) contains following `JAVA_OPTS` defaults:

```auto
JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"

```

It seems there is no way to disable them at the moment. This is  
causing issues when one wants to enable G1GC instead. How about making these defaults conditional?

Please advise

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [December 14, 2015, 7:04pm UTC](https://discuss.elastic.co/t/default-java-opts-in-elasticsearch-in-sh/37095/2 "2015-12-14T19:04:20Z")

</div>

Well, those are the recommended Java options for Elasticsearch, and we don't really recommend changing them 😄

G1GC is not recommended because we still see it throw fatal exceptions, index corruptions, etc due to bugs. For example, the recent [8u60 release had a handful of G1 related bugs](http://www.oracle.com/technetwork/java/javase/2col/8u60-bugfixes-2620228.html).

Lucene tests against G1 regularly and finds index-corrupting errors as well. From [Lucene's "known java bugs"](https://wiki.apache.org/lucene-java/JavaBugs) page:

> Do not, under any circumstances, run Lucene with the G1 garbage collector. Lucene's test suite fails with the G1 garbage collector on a regular basis, including bugs that cause index corruption. There is no person on this planet that seems to understand such bugs (see [Loading...](https://bugs.openjdk.java.net/browse/JDK-8038348), open for over a year), so don't count on the situation changing soon.

So, morale of the story is don't use G1GC yet =)

If you absolutely must change the java options, you'll simply have to change the `elasticsearch.in.sh` script. But then you are essentially running "unsupported" and any issues you encounter will likely need to set back to default before anyone will be able to help, since ES is designed/tested against those defaults.

---

<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:** [July 5, 2017, 11:31pm UTC](https://discuss.elastic.co/t/default-java-opts-in-elasticsearch-in-sh/37095/3 "2017-07-05T23:31:11Z")

</div>


