# Recurring Heap Problems

**URL:** <https://discuss.elastic.co/t/recurring-heap-problems/20378>\
**Category:** Elasticsearch\
**Created:** [October 22, 2014, 9:19am UTC](https://discuss.elastic.co/t/recurring-heap-problems/20378 "2014-10-22T09:19:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Bernardi](https://avatars.discourse-cdn.com/v4/letter/v/e79b87/32.png) [@Vincent\_Bernardi](https://discuss.elastic.co/u/Vincent_Bernardi)\
**Post date:** [October 22, 2014, 9:19am UTC](https://discuss.elastic.co/t/recurring-heap-problems/20378/1 "2014-10-22T09:19:34Z")

</div>

Hello ES group,  
I have had recurring heap problems ("java.lang.OutOfMemoryError: Java heap  
space”) on my 2-nodes ES cluster (16GB RAM/node, 8GB allocated to ES) the  
last month and I really don’t know how to tackle them.  
It started at a time where I was doing aggregations on a “milliseconds  
since EPOCH” field, and I was given to understand that it was probably the  
cause of my problems since it created a very large number of buckets before  
aggregating them. So I stopped doing aggregations on this field (I did not  
delete it though).  
Recently I was told that my index had too few shards respective to its size  
(2 primary shards, 1 replica each, 100-150 Mdocs). So I decided to try  
reindexing into a new index with more shards (I am using es-reindex.rb,  
which itself uses the bulk API). But now I am having OutOfMemoryError happen  
during reindexing. Needless to say, once an OutOfMemoryError happens, my  
cluster seems to never recover until I reboot each node.  
It should be noted that I use ES almost exclusively with search\_type=count,  
since I am only trying to do analytics on website data.  
I am not sure how to proceed from this point, I don’t know the right tool  
to pinpoint my memory problems and there doesn’t seem to be a way to ask ES  
for heap usage by index/query/task type  
I’d be very grateful for any advice you can offer.  
Thanks in advance,  
Vincent Bernardi

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4687cf5b-34c8-4f5d-88be-f134367a888b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4687cf5b-34c8-4f5d-88be-f134367a888b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Arie](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Arie](https://discuss.elastic.co/u/Arie)\
**Post date:** [October 22, 2014, 9:50am UTC](https://discuss.elastic.co/t/recurring-heap-problems/20378/2 "2014-10-22T09:50:48Z")

</div>

In my situation I had configured ES\_HEAP\_SIZE in the yml file with no  
effectt (on centos 6.5)  
ES was running with default memory configured allways. This is evenso with  
ES 1.3.4.

My solution was to configure this in /etc/init.d/elasticsearch

Another setting that can be helpfull:

```
indices.fielddata.cache.size: 40%

```

On Wednesday, October 22, 2014 11:19:34 AM UTC+2, Vincent Bernardi wrote:

> Hello ES group,  
> I have had recurring heap problems ("java.lang.OutOfMemoryError: Java  
> heap space”) on my 2-nodes ES cluster (16GB RAM/node, 8GB allocated to  
> ES) the last month and I really don’t know how to tackle them.  
> It started at a time where I was doing aggregations on a “milliseconds  
> since EPOCH” field, and I was given to understand that it was probably the  
> cause of my problems since it created a very large number of buckets before  
> aggregating them. So I stopped doing aggregations on this field (I did not  
> delete it though).  
> Recently I was told that my index had too few shards respective to its  
> size (2 primary shards, 1 replica each, 100-150 Mdocs). So I decided to try  
> reindexing into a new index with more shards (I am using es-reindex.rb,  
> which itself uses the bulk API). But now I am having OutOfMemoryError happen  
> during reindexing. Needless to say, once an OutOfMemoryError happens, my  
> cluster seems to never recover until I reboot each node.  
> It should be noted that I use ES almost exclusively with  
> search\_type=count, since I am only trying to do analytics on website data.  
> I am not sure how to proceed from this point, I don’t know the right tool  
> to pinpoint my memory problems and there doesn’t seem to be a way to ask ES  
> for heap usage by index/query/task type  
> I’d be very grateful for any advice you can offer.  
> Thanks in advance,  
> Vincent Bernardi

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e133f38e-7e1c-40e1-a40c-2b8a8d8a4a86%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e133f38e-7e1c-40e1-a40c-2b8a8d8a4a86%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:54am UTC](https://discuss.elastic.co/t/recurring-heap-problems/20378/3 "2017-07-06T00:54:29Z")

</div>


