# OutOfMemoryError from field cache

**URL:** https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313
**Category:** Elasticsearch
**Created:** [January 8, 2012, 2:56am UTC](https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313 "2012-01-08T02:56:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jason\_2](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jason\_2](https://discuss.elastic.co/u/Jason_2)
#### Post date: [January 8, 2012, 2:56am UTC](https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313/1 "2012-01-08T02:56:46Z")

</div>

I'm trying to debug OutOfMemory errors that keep happening in our  
elastic cluster. I've been monitoring statistics once a minute before  
the error occurs. The problem seems to be from the field data cache.  
I've seen other discussions about the need for the field data cache  
with facet and sort searches but this cluster is only being used for  
indexing right now. While monitoring the statistics I see the query  
count go up every time the problem happens. I was wondering if  
elasticsearch was querying itself in order to warm the field data  
cache. Does it do this or does it wait until a real query comes in?

Statistics at one minute.  
"search" : {  
"query\_total" : 0,  
"query\_time" : "0s",  
"query\_time\_in\_millis" : 0,  
"query\_current" : 0,  
"fetch\_total" : 0,  
"fetch\_time" : "0s",  
"fetch\_time\_in\_millis" : 0,  
"fetch\_current" : 0  
},  
"cache" : {  
"field\_evictions" : 0,  
"field\_size" : "0b",  
"field\_size\_in\_bytes" : 0,  
"filter\_count" : 0,  
"filter\_evictions" : 0,  
"filter\_size" : "0b",  
"filter\_size\_in\_bytes" : 0  
},

The next minute. We're configured with 20 gigs for each node so this  
quickly causes the OutOfMemoryError.  
"search" : {  
"query\_total" : 1,  
"query\_time" : "16.5s",  
"query\_time\_in\_millis" : 16543,  
"query\_current" : 0,  
"fetch\_total" : 0,  
"fetch\_time" : "0s",  
"fetch\_time\_in\_millis" : 0,  
"fetch\_current" : 0  
},  
"cache" : {  
"field\_evictions" : 0,  
"field\_size" : "13.4gb",  
"field\_size\_in\_bytes" : 14475278126,  
"filter\_count" : 3,  
"filter\_evictions" : 0,  
"filter\_size" : "26.7mb",  
"filter\_size\_in\_bytes" : 28089832  
},

---

<div class="post-metadata">

### Author: ![Gustavo\_Maia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavo_maia/32/2183_2.png) [@Gustavo\_Maia](https://discuss.elastic.co/u/Gustavo_Maia)
#### Post date: [January 8, 2012, 3:58pm UTC](https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313/2 "2012-01-08T15:58:31Z")

</div>

I have the same problem.

Today, I have a million of documents and 4 million document tag when I  
do in every facet documents, I have a problem with OutOfMemory. I  
started the JVM with 4GB.

2012/1/8 Jason [jason@element84.com](mailto:jason@element84.com):

> I'm trying to debug OutOfMemory errors that keep happening in our  
> elastic cluster. I've been monitoring statistics once a minute before  
> the error occurs. The problem seems to be from the field data cache.  
> I've seen other discussions about the need for the field data cache  
> with facet and sort searches but this cluster is only being used for  
> indexing right now. While monitoring the statistics I see the query  
> count go up every time the problem happens. I was wondering if  
> elasticsearch was querying itself in order to warm the field data  
> cache. Does it do this or does it wait until a real query comes in?
> 
> Statistics at one minute.  
> "search" : {  
> "query\_total" : 0,  
> "query\_time" : "0s",  
> "query\_time\_in\_millis" : 0,  
> "query\_current" : 0,  
> "fetch\_total" : 0,  
> "fetch\_time" : "0s",  
> "fetch\_time\_in\_millis" : 0,  
> "fetch\_current" : 0  
> },  
> "cache" : {  
> "field\_evictions" : 0,  
> "field\_size" : "0b",  
> "field\_size\_in\_bytes" : 0,  
> "filter\_count" : 0,  
> "filter\_evictions" : 0,  
> "filter\_size" : "0b",  
> "filter\_size\_in\_bytes" : 0  
> },
> 
> The next minute. We're configured with 20 gigs for each node so this  
> quickly causes the OutOfMemoryError.  
> "search" : {  
> "query\_total" : 1,  
> "query\_time" : "16.5s",  
> "query\_time\_in\_millis" : 16543,  
> "query\_current" : 0,  
> "fetch\_total" : 0,  
> "fetch\_time" : "0s",  
> "fetch\_time\_in\_millis" : 0,  
> "fetch\_current" : 0  
> },  
> "cache" : {  
> "field\_evictions" : 0,  
> "field\_size" : "13.4gb",  
> "field\_size\_in\_bytes" : 14475278126,  
> "filter\_count" : 3,  
> "filter\_evictions" : 0,  
> "filter\_size" : "26.7mb",  
> "filter\_size\_in\_bytes" : 28089832  
> },

--  
Gustavo Maia

---

<div class="post-metadata">

### Author: ![Jason\_2](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jason\_2](https://discuss.elastic.co/u/Jason_2)
#### Post date: [January 11, 2012, 1:19pm UTC](https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313/3 "2012-01-11T13:19:41Z")

</div>

I added "index.cache.field.type: soft" to our elastic config and this  
has fixed the problem. Search performance isn't any worse. We don't  
use facet search over the majority of our documents and we only sort  
on two fields. My theory is that the resident cache is putting more  
than the two sort fields in memory or all of the values in the two  
sort fields are more than we have memory to accomodate. The fields  
we're sorting on are an id field and a date field. The id field only  
a dozen unique values across 100 million records. I want to try and  
calculate how much memory the fields must be taking. I could probably  
try to determine this by starting with an empty index and adding 10  
documents then execute a query with sorting that will find all of  
them. Then I could check the statistics to see how much memory is  
allocated to the field cache.

On Jan 8, 10:58 am, Gustavo Maia [gustavobbm...@gmail.com](mailto:gustavobbm...@gmail.com) wrote:

> I have the same problem.
> 
> Today, I have a million of documents and 4 million document tag when I  
> do in every facet documents, I have a problem with OutOfMemory. I  
> started the JVM with 4GB.
> 
> 2012/1/8 Jason [ja...@element84.com](mailto:ja...@element84.com):
> 
> > I'm trying to debug OutOfMemory errors that keep happening in our  
> > elastic cluster. I've been monitoring statistics once a minute before  
> > the error occurs. The problem seems to be from the field data cache.  
> > I've seen other discussions about the need for the field data cache  
> > with facet and sort searches but this cluster is only being used for  
> > indexing right now. While monitoring the statistics I see the query  
> > count go up every time the problem happens. I was wondering if  
> > elasticsearch was querying itself in order to warm the field data  
> > cache. Does it do this or does it wait until a real query comes in?
> 
> > Statistics at one minute.  
> > "search" : {  
> > "query\_total" : 0,  
> > "query\_time" : "0s",  
> > "query\_time\_in\_millis" : 0,  
> > "query\_current" : 0,  
> > "fetch\_total" : 0,  
> > "fetch\_time" : "0s",  
> > "fetch\_time\_in\_millis" : 0,  
> > "fetch\_current" : 0  
> > },  
> > "cache" : {  
> > "field\_evictions" : 0,  
> > "field\_size" : "0b",  
> > "field\_size\_in\_bytes" : 0,  
> > "filter\_count" : 0,  
> > "filter\_evictions" : 0,  
> > "filter\_size" : "0b",  
> > "filter\_size\_in\_bytes" : 0  
> > },
> 
> > The next minute. We're configured with 20 gigs for each node so this  
> > quickly causes the OutOfMemoryError.  
> > "search" : {  
> > "query\_total" : 1,  
> > "query\_time" : "16.5s",  
> > "query\_time\_in\_millis" : 16543,  
> > "query\_current" : 0,  
> > "fetch\_total" : 0,  
> > "fetch\_time" : "0s",  
> > "fetch\_time\_in\_millis" : 0,  
> > "fetch\_current" : 0  
> > },  
> > "cache" : {  
> > "field\_evictions" : 0,  
> > "field\_size" : "13.4gb",  
> > "field\_size\_in\_bytes" : 14475278126,  
> > "filter\_count" : 3,  
> > "filter\_evictions" : 0,  
> > "filter\_size" : "26.7mb",  
> > "filter\_size\_in\_bytes" : 28089832  
> > },
> 
> --  
> Gustavo Maia

---

<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, 3:43am UTC](https://discuss.elastic.co/t/outofmemoryerror-from-field-cache/6313/4 "2017-07-06T03:43:08Z")

</div>


