# java.lang.OutOfMemoryError: Java heap space with search action

**URL:** https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-with-search-action/131296
**Category:** Elasticsearch
**Created:** [May 10, 2018, 11:31am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-with-search-action/131296 "2018-05-10T11:31:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![an.secure](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@an.secure](https://discuss.elastic.co/u/an.secure)
#### Post date: [May 10, 2018, 11:31am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-with-search-action/131296/1 "2018-05-10T11:31:27Z")

</div>

Seeing the below stack trace in elasticsearch logs. What may be the possible cause for this :

[E] asticsearchUncaughtExceptionHandler - [UID=] - fatal error in thread [elasticsearch[node01][search][T#1]], exiting  
java.lang.OutOfMemoryError: Java heap space  
at com.fasterxml.jackson.core.util.TextBuffer.carr(TextBuffer.java:778) ~[jackson-core-2.8.1.jar:2.8.1]  
at com.fasterxml.jackson.core.util.TextBuffer.finishCurrentSegment(TextBuffer.java:632) ~[jackson-core-2.8.1.jar:2.8.1]  
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.\_finishString2(UTF8StreamJsonParser.java:2489) ~[jackson-core-2.8.1.jar:2.8.1]  
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.\_finishAndReturnString(UTF8StreamJsonParser.java:2465) ~[jackson-core-2.8.1.jar:2.8.1]  
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:315) ~[jackson-core-2.8.1.jar:2.8.1]  
at org.elasticsearch.common.xcontent.json.JsonXContentParser.text(JsonXContentParser.java:83) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.readValue(AbstractXContentParser.java:347) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.readMap(AbstractXContentParser.java:295) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.readMap(AbstractXContentParser.java:258) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.map(AbstractXContentParser.java:213) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:81) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.lookup.SourceLookup.sourceAsMapAndType(SourceLookup.java:89) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.lookup.SourceLookup.loadSourceIfNeeded(SourceLookup.java:65) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.lookup.SourceLookup.filter(SourceLookup.java:135) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase.hitExecute(FetchSourceSubPhase.java:51) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:163) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:502) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.action.search.SearchTransportService$13.messageReceived(SearchTransportService.java:356) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.action.search.SearchTransportService$13.messageReceived(SearchTransportService.java:353) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:577) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.1.1.jar:5.1.1]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0\_152]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0\_152]  
at java.lang.Thread.run(Thread.java:748) [?:1.8.0\_152]  
2018-05-10T10:13:09,790 search][T#6] [E] asticsearchUncaughtExceptionHandler - [UID=] - fatal error in thread [elasticsearch[node01][search][T#6]], exiting  
java.lang.OutOfMemoryError: Java heap space  
at org.apache.lucene.codecs.compressing.CompressingStoredFieldsReader.readField(CompressingStoredFieldsReader.java:214) ~[lucene-core-6.3.0.jar:6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:47:11]  
at org.apache.lucene.codecs.compressing.CompressingStoredFieldsReader.visitDocument(CompressingStoredFieldsReader.java:595) ~[lucene-core-6.3.0.jar:6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:47:11]  
at org.apache.lucene.index.CodecReader.document(CodecReader.java:88) ~[lucene-core-6.3.0.jar:6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:47:11]  
at org.apache.lucene.index.FilterLeafReader.document(FilterLeafReader.java:411) ~[lucene-core-6.3.0.jar:6.3.0 a66a44513ee8191e25b477372094bfa846450316 - shalin - 2016-11-02 19:47:11]  
at org.elasticsearch.search.fetch.FetchPhase.loadStoredFields(FetchPhase.java:349) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.fetch.FetchPhase.createSearchHit(FetchPhase.java:188) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:154) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:502) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.action.search.SearchTransportService$13.messageReceived(SearchTransportService.java:356) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.action.search.SearchTransportService$13.messageReceived(SearchTransportService.java:353) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:577) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527) ~[elasticsearch-5.1.1.jar:5.1.1]  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.1.1.jar:5.1.1]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0\_152]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0\_152]  
at java.lang.Thread.run(Thread.java:748) [?:1.8.0\_152]

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [May 10, 2018, 3:44pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-with-search-action/131296/2 "2018-05-10T15:44:08Z")

</div>

I think you'll have to provide more info. The stacktrace doesn't really provide much information, just that you ran out of memory.

What query was run? Does a single type of query consistently OOM the node? Was any other activity going on to use up heap space?

What version of Elasticsearch are you running?

If I had to guess, I'd say there was a very large aggregation that ran, and overflowed the heap due to too many buckets. But it's hard to say without more info.

---

<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 7, 2018, 3:47pm UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-with-search-action/131296/3 "2018-06-07T15:47:36Z")

</div>

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