# Where to set Heap memory - jvm.options or /etc/sysconfig/elasticsearch

**URL:** <https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082>\
**Category:** Elasticsearch\
**Created:** [January 29, 2019, 5:06am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082 "2019-01-29T05:06:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [January 29, 2019, 5:06am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082/1 "2019-01-29T05:06:09Z")

</div>

I know that heap memory has to be set in jvm.options file.  
-Xms2g  
-Xms2g

But I can see in /etc/sysconfig/elasticsearch file also we can set heap memory.

# Heap Size (defaults to 256m min, 1g max)

#ES\_HEAP\_SIZE=2g

Which is the correct place to set heap memory for ES?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 29, 2019, 5:25am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082/2 "2019-01-29T05:25:42Z")

</div>

Prefer jvm.options.

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html)

---

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [January 29, 2019, 5:36am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082/3 "2019-01-29T05:36:14Z")

</div>

Thanks...So we should prefer to set heap memory in jvm.options.  
But consider the case, if someone by mistake has configured in both places and in jvm.options he mentioned 4g heap size but in env variable in elasticsearch file he mentioned ES\_HEAP\_SIZE=2g..

Then which one will be effective? 4g or 2g?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 29, 2019, 5:56am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082/4 "2019-01-29T05:56:22Z")

</div>

I don't know. Try it and look what elasticsearch reports.

---

<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:** [February 26, 2019, 6:09am UTC](https://discuss.elastic.co/t/where-to-set-heap-memory-jvm-options-or-etc-sysconfig-elasticsearch/166082/5 "2019-02-26T06:09:17Z")

</div>

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