# JVM Heap size issue. ElasticSearch stops sometimes due to this error

**URL:** <https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157>\
**Category:** Elasticsearch\
**Created:** [May 11, 2023, 5:52am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157 "2023-05-11T05:52:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![theacodes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theacodes/32/113779_2.png) [@theacodes](https://discuss.elastic.co/u/theacodes)\
**Post date:** [May 11, 2023, 5:52am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/1 "2023-05-11T05:52:30Z")

</div>

Caused by: org.elasticsearch.common.breaker.CircuitBreakingException: [parent] Data too large, data for [preallocate[aggregations]] would be [4143070784/3.8gb], which is larger than the limit of [4080218931/3.7gb], real usage: [4143064640/3.8gb],

Hello, there is a total of 1 node in the cluster. 1 master node only.  
The master node has 64 GB ram. But the JVM heap is set to 4 GB.

-Xms4g  
-Xmx4g

guide me on what should I do...

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 11, 2023, 5:57am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/2 "2023-05-11T05:57:06Z")

</div>

Increase the size of the heap. Go to 8GB and see how that works out.

---

<div class="post-metadata">

**Author:** ![theacodes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theacodes/32/113779_2.png) [@theacodes](https://discuss.elastic.co/u/theacodes)\
**Post date:** [May 11, 2023, 6:00am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/3 "2023-05-11T06:00:06Z")

</div>

Hi @Christian_Dahlqvist

I've read the alternatives like you said but can you please tell me what is the right way?  
I tried changing it to  
-Xms8g  
-Xmx8g  
in my local VM ELK setup but the Elastic service failed to start.

Should I change the jvm.options file and how?  
Any other option for that but how?  
Please guide if you know the solution

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 11, 2023, 6:02am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/4 "2023-05-11T06:02:27Z")

</div>

Is there anything else running on the VM? If the VM has 64GB of RAM and only hosts Elasticsearch there should be no problem.

The heap should be set to no more than 50% of the RAM available to Elasticsearch. With a 8G heap Elasticsearch requires 16GB of RAM to be available to it.

---

<div class="post-metadata">

**Author:** ![theacodes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theacodes/32/113779_2.png) [@theacodes](https://discuss.elastic.co/u/theacodes)\
**Post date:** [May 11, 2023, 6:07am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/5 "2023-05-11T06:07:53Z")

</div>

Oh yeah that's right nothing like another heavy tool running on the server having 64 GB of RAM  
but what I meant earlier was that before executing these settings on my Actual ELK Server I tried it on a replica VM machine to test if it works and it failed.

So with 64 GB of RAM let's say I want to set JVM heap to 16 GB  
what would be the steps I should take? what file and setting should I modify and in what manner?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 11, 2023, 6:12am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/6 "2023-05-11T06:12:56Z")

</div>

You change the jvm options file, which is where I assume you got the settings you initially showed, and restart Elasticsearch.

---

<div class="post-metadata">

**Author:** ![theacodes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theacodes/32/113779_2.png) [@theacodes](https://discuss.elastic.co/u/theacodes)\
**Post date:** [May 11, 2023, 6:26am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/7 "2023-05-11T06:26:30Z")

</div>

okay so changing only the below settings like this

-Xms16g  
-Xmx16g

and nothing else in the JVM options file and restarting would do the work??

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [May 11, 2023, 6:27am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/8 "2023-05-11T06:27:50Z")

</div>

Yes, that's it and set in `config/jvm.options.d/jvm.options` not in config/jvm.options.

---

<div class="post-metadata">

**Author:** ![theacodes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theacodes/32/113779_2.png) [@theacodes](https://discuss.elastic.co/u/theacodes)\
**Post date:** [May 11, 2023, 6:34am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/9 "2023-05-11T06:34:51Z")

</div>

So you're saying in this below location

`config/jvm.options.d/jvm.options`

the only thing I should write in the file is the below two lines:

-Xms16g  
-Xmx16g

and nothing else  
and what about jvm.options original file? any changes to be done in that file?

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [May 11, 2023, 8:33am UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/10 "2023-05-11T08:33:30Z")

</div>

Yes, exactly `config/jvm.options.d/jvm.options`

> what about jvm.options original file?  
> Well that should Elastic team members respond. Read [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html#set-jvm-options).

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [May 15, 2023, 7:55pm UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/11 "2023-05-15T19:55:13Z")

</div>

Don't modify `jvm.options` since your custom settings could be overwritten by a future update of Elasticsearch (depending on the installation method)

---

<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:** [June 12, 2023, 7:55pm UTC](https://discuss.elastic.co/t/jvm-heap-size-issue-elasticsearch-stops-sometimes-due-to-this-error/333157/12 "2023-06-12T19:55:36Z")

</div>

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