# What is the recommended Java heap size for Elasticsearch?

**URL:** <https://discuss.elastic.co/t/what-is-the-recommended-java-heap-size-for-elasticsearch/73>\
**Category:** Elasticsearch\
**Created:** [April 30, 2015, 11:23pm UTC](https://discuss.elastic.co/t/what-is-the-recommended-java-heap-size-for-elasticsearch/73 "2015-04-30T23:23:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [April 30, 2015, 11:23pm UTC](https://discuss.elastic.co/t/what-is-the-recommended-java-heap-size-for-elasticsearch/73/1 "2015-04-30T23:23:44Z")

</div>

It depends on what you will be doing. If you use faceting, aggregations, or parent/child queries you will need more heap space. It might make sense to run some performance tests and monitor the heap to figure out what a good heap size would be.

Regardless, we do not recommend setting heap larger than **31GB** and not more than half available memory, whichever is lower. (e.g. 128GB of available memory = max 30GB heap, 64GB of available memory = max 31GB heap, 32GB of available memory = max 16GB heap). This upper limit is required to ensure the underlying Lucene software can make use of compressed pointers, which offer a major performance gain.

---

<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 6, 2017, 12:16am UTC](https://discuss.elastic.co/t/what-is-the-recommended-java-heap-size-for-elasticsearch/73/2 "2017-07-06T00:16:26Z")

</div>


