# Memory -Xmx and -Xms "should" be the same... how severely "should" we heed this recommendation?

**URL:** <https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737>\
**Category:** Elasticsearch\
**Created:** [October 20, 2020, 8:39pm UTC](https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737 "2020-10-20T20:39:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjcjameson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcjameson/32/77560_2.png) [@cjcjameson](https://discuss.elastic.co/u/cjcjameson)\
**Post date:** [October 20, 2020, 8:39pm UTC](https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737/1 "2020-10-20T20:39:25Z")

</div>

[https://github.com/elastic/elasticsearch/blob/master/docs/reference/setup/important-settings/heap-size.asciidoc#heap-size-settings](https://github.com/elastic/elasticsearch/blob/master/docs/reference/setup/important-settings/heap-size.asciidoc#heap-size-settings) mentions:

```auto
Elasticsearch will assign the entire heap specified in jvm.options via the Xms (minimum heap size) and Xmx (maximum heap size) settings. You should set these two settings to equal each other.

```

This "should" has been around for a while, but we can't find specific information about this recommendation.

- In what situations "must" we set the values to be the same?
- In what situations is it reasonable to set a different value?
- Is it reasonable to set `-Xms 64m` and then have `-Xmx` scale relative to the physical memory on the machine (less than 50% of the allocatable memory)?

Our context is that we are bundling Elasticsearch to be deployed on machines together with other data analytics applications. So we need to "play nicely" with other Java services, and we are thinking to not pre-allocate too much heap, unless it's necessary.

We have evaluated our particular indices usage of Elasticsearch's layers of caches, and feel like if the heap allocation is decreased during operation (evicting some cache), it wouldn't significantly affect our operations.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 20, 2020, 10:32pm UTC](https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737/2 "2020-10-20T22:32:18Z")

</div>

That `-Xms` and `-Xmx` are set to the same value is enforced by a [bootstrap check](https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html) at startup, so it's not even possible to set them to different values when running in production.

---

<div class="post-metadata">

**Author:** ![cjcjameson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcjameson/32/77560_2.png) [@cjcjameson](https://discuss.elastic.co/u/cjcjameson)\
**Post date:** [October 23, 2020, 12:33am UTC](https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737/3 "2020-10-23T00:33:35Z")

</div>

Ok. [https://github.com/elastic/elasticsearch/pull/64090](https://github.com/elastic/elasticsearch/pull/64090) to clarify

---

<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 20, 2020, 12:33am UTC](https://discuss.elastic.co/t/memory-xmx-and-xms-should-be-the-same-how-severely-should-we-heed-this-recommendation/252737/4 "2020-11-20T00:33:40Z")

</div>

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