# ElasticSearch out of memory with static field index cache size

**URL:** https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742
**Category:** Elasticsearch
**Created:** [September 24, 2013, 9:24pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742 "2013-09-24T21:24:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Joseph\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Joseph\_Smith](https://discuss.elastic.co/u/Joseph_Smith)
#### Post date: [September 24, 2013, 9:24pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/1 "2013-09-24T21:24:59Z")

</div>

I have been running a cluster of ES servers (5) with 48GB of RAM. They have  
32 GB allocated to the ES process and are configured to use a static  
maximum 60% of that RAM for the index field cache. They have been running  
with this configuration for weeks.

I have a jmx ganglia plugin that shows the servers hovering right around  
28GB of JVM Heap usage for the last few weeks.

This morning the memory the leader of the cluster spiked to fill the entire  
JVM allocated size (32 GB) and then further spiked to 35GB a few minutes  
later (I am guessing this is while it was writing the heap dump).

The odd thing is that the amount of data being indexed at the time was  
below the average that we had been indexing during the last few weeks. As  
far as I can tell, there were no unconventional index or search requests at  
that time.

The logs don't show anything helpful - just a bunch of GC's starting at the  
memory spike time and then a bunch of out of memory exceptions (nothing  
surprising).

Given that the index field cache size is fixed (and I have verified this  
with various tests over the last few weeks), I am not sure what is causing  
this sudden spike in memory.

Could optimizing or flushing cause such a spike?

This is what the top few largest memory objects from Eclipse MAT look like:

[https://lh6.googleusercontent.com/-a-Xz8E-zOm8/UkIC6D7XiuI/AAAAAAAAAFI/aVs9qA3PAb4/s1600/screenshot89.jpg](https://lh6.googleusercontent.com/-a-Xz8E-zOm8/UkIC6D7XiuI/AAAAAAAAAFI/aVs9qA3PAb4/s1600/screenshot89.jpg)

Thanks in advance for any help,  
~joe!

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [September 25, 2013, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/2 "2013-09-25T07:27:16Z")

</div>

What ES version and JVM is this?

Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Joseph\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Joseph\_Smith](https://discuss.elastic.co/u/Joseph_Smith)
#### Post date: [September 25, 2013, 2:19pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/3 "2013-09-25T14:19:30Z")

</div>

My apologies for not including this in the original post:

ES version: 0.90.2  
java version "1.7.0\_09-icedtea"  
OpenJDK Runtime Environment (rhel-2.3.8.0.el6\_4-x86\_64)  
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

On Wednesday, September 25, 2013 3:27:16 AM UTC-4, Jörg Prante wrote:

> What ES version and JVM is this?
> 
> Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Joseph\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Joseph\_Smith](https://discuss.elastic.co/u/Joseph_Smith)
#### Post date: [September 25, 2013, 2:21pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/4 "2013-09-25T14:21:35Z")

</div>

JVM flags:

java -Xms32g -Xmx32g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:-UseG1GC  
-XX:HeapDumpPath=/var/log/elasticsearch

Note that we do not use G1GC because there is an issue with some of the  
concurrent containers in ES when used in conjunction with G1GC.

~joe!

On Wednesday, September 25, 2013 10:19:30 AM UTC-4, Joseph Smith wrote:

> My apologies for not including this in the original post:
> 
> ES version: 0.90.2  
> java version "1.7.0\_09-icedtea"  
> OpenJDK Runtime Environment (rhel-2.3.8.0.el6\_4-x86\_64)  
> OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
> 
> On Wednesday, September 25, 2013 3:27:16 AM UTC-4, Jörg Prante wrote:
> 
> > What ES version and JVM is this?
> > 
> > Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Joseph\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Joseph\_Smith](https://discuss.elastic.co/u/Joseph_Smith)
#### Post date: [September 25, 2013, 5:20pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/5 "2013-09-25T17:20:15Z")

</div>

I've also noticed that once in a while a server will just to a very high  
field cache size, despite my configuration.

In elasticsearch.yaml, I have: indices.fielddata.cache.size: 50%.

In my mapping, I have: "index.fielddata.cache" : "node".

Most of the time the servers stay fixed at around 13-15GB (50% of the JVM  
heap size), but once in a while one will suddenly go up to: 21-26GB, which  
is much more than I specified.

~joe!

On Wednesday, September 25, 2013 10:21:35 AM UTC-4, Joseph Smith wrote:

> JVM flags:
> 
> java -Xms32g -Xmx32g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
> -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
> -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
> -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:-UseG1GC  
> -XX:HeapDumpPath=/var/log/elasticsearch
> 
> Note that we do not use G1GC because there is an issue with some of the  
> concurrent containers in ES when used in conjunction with G1GC.
> 
> ~joe!
> 
> On Wednesday, September 25, 2013 10:19:30 AM UTC-4, Joseph Smith wrote:
> 
> > My apologies for not including this in the original post:
> > 
> > ES version: 0.90.2  
> > java version "1.7.0\_09-icedtea"  
> > OpenJDK Runtime Environment (rhel-2.3.8.0.el6\_4-x86\_64)  
> > OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
> > 
> > On Wednesday, September 25, 2013 3:27:16 AM UTC-4, Jörg Prante wrote:
> > 
> > > What ES version and JVM is this?
> > > 
> > > Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Joseph\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Joseph\_Smith](https://discuss.elastic.co/u/Joseph_Smith)
#### Post date: [September 25, 2013, 9:56pm UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/6 "2013-09-25T21:56:40Z")

</div>

So I have narrowed this down to the following problem:

If I specify a static fielddata cache size with a large value, say 16gb,  
then the value is ignored and I eventually OOM.

If I instead use a small value, say 2gb, then the field data cache size  
stays within the specified limit.

I have now tested this with the latest Oracle/Sun JDK and with OpenJDK. It  
repros in both scenarios.

~joe!

On Wednesday, September 25, 2013 1:20:15 PM UTC-4, Joseph Smith wrote:

> I've also noticed that once in a while a server will just to a very high  
> field cache size, despite my configuration.
> 
> In elasticsearch.yaml, I have: indices.fielddata.cache.size: 50%.
> 
> In my mapping, I have: "index.fielddata.cache" : "node".
> 
> Most of the time the servers stay fixed at around 13-15GB (50% of the JVM  
> heap size), but once in a while one will suddenly go up to: 21-26GB, which  
> is much more than I specified.
> 
> ~joe!
> 
> On Wednesday, September 25, 2013 10:21:35 AM UTC-4, Joseph Smith wrote:
> 
> > JVM flags:
> > 
> > java -Xms32g -Xmx32g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC  
> > -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75  
> > -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError  
> > -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:-UseG1GC  
> > -XX:HeapDumpPath=/var/log/elasticsearch
> > 
> > Note that we do not use G1GC because there is an issue with some of the  
> > concurrent containers in ES when used in conjunction with G1GC.
> > 
> > ~joe!
> > 
> > On Wednesday, September 25, 2013 10:19:30 AM UTC-4, Joseph Smith wrote:
> > 
> > > My apologies for not including this in the original post:
> > > 
> > > ES version: 0.90.2  
> > > java version "1.7.0\_09-icedtea"  
> > > OpenJDK Runtime Environment (rhel-2.3.8.0.el6\_4-x86\_64)  
> > > OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
> > > 
> > > On Wednesday, September 25, 2013 3:27:16 AM UTC-4, Jörg Prante wrote:
> > > 
> > > > What ES version and JVM is this?
> > > > 
> > > > Jörg

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:14am UTC](https://discuss.elastic.co/t/elasticsearch-out-of-memory-with-static-field-index-cache-size/13742/7 "2017-07-06T02:14:40Z")

</div>


