# Elasticsearch-5.2.0 java.lang.OutOfMemoryError: Java heap space

**URL:** https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483
**Category:** Elasticsearch
**Created:** [February 25, 2017, 2:44pm UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483 "2017-02-25T14:44:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![blair319](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@blair319](https://discuss.elastic.co/u/blair319)
#### Post date: [February 25, 2017, 2:44pm UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483/1 "2017-02-25T14:44:21Z")

</div>

Elasticsearch version:5.2.0

Plugins installed: []

JVM version:1.8.0\_121

OS version:redhat

config/jvm.options

-Xms20g  
-Xmx20g

-XX:+UseCondCardMark  
-XX:CMSWaitDuration=250

-XX:+UseG1GC  
-XX:MaxGCPauseMillis=200

=============================================================================

I need to configure how to solve this problem?  
and how to optimize index?

[2017-02-25T22:24:23,840][INFO][o.e.m.j.JvmGcMonitorService] [node-3] [gc][young][2829][54] duration [1.6s], collections [2]/[2.4s], total [1.6s]/[8.1s], memory [10.6gb]-\>[6.2gb]/[20gb], all\_pools {[young] [8.8gb]-\>[8mb]/[0b]}{[survivor] [40mb]-\>[72mb]/[0b]}{[old] [1.7gb]-\>[6.2gb]/[20gb]}  
[2017-02-25T22:24:23,841][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2829] overhead, spent [1.6s] collecting in the last [2.4s]  
[2017-02-25T22:24:24,841][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2830] overhead, spent [653ms] collecting in the last [1s]  
[2017-02-25T22:24:25,869][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2831] overhead, spent [591ms] collecting in the last [1s]  
[2017-02-25T22:24:26,908][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2832] overhead, spent [710ms] collecting in the last [1s]  
[2017-02-25T22:24:27,957][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2833] overhead, spent [703ms] collecting in the last [1s]  
[2017-02-25T22:24:29,070][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2834] overhead, spent [733ms] collecting in the last [1.1s]  
[2017-02-25T22:24:30,071][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2835] overhead, spent [747ms] collecting in the last [1s]  
[2017-02-25T22:24:39,251][INFO][o.e.m.j.JvmGcMonitorService] [node-3] [gc][old][2836][1] duration [8.1s], collections [1]/[9.1s], total [8.1s]/[8.1s], memory [17.9gb]-\>[18.1gb]/[20gb], all\_pools {[young] [304mb]-\>[8mb]/[0b]}{[survivor] [128mb]-\>[0b]/[0b]}{[old] [17.5gb]-\>[18.1gb]/[20gb]}  
[2017-02-25T22:24:39,251][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2836] overhead, spent [8.8s] collecting in the last [9.1s]  
[2017-02-25T22:24:42,208][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2837] overhead, spent [2.7s] collecting in the last [2.9s]  
[2017-02-25T22:24:44,980][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2838] overhead, spent [2.6s] collecting in the last [2.7s]  
[2017-02-25T22:24:47,093][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2839] overhead, spent [2s] collecting in the last [2.1s]  
[2017-02-25T22:24:48,403][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2840] overhead, spent [1.3s] collecting in the last [1.3s]  
[2017-02-25T22:26:55,561][WARN][o.e.m.j.JvmGcMonitorService] [node-3] [gc][2841] overhead, spent [1.2m] collecting in the last [2.1m]  
[2017-02-25T22:26:55,584][WARN][o.e.d.z.PublishClusterStateAction] [node-3] received a cluster state from a different master than the current one, rejecting (received {node-4}{5BRY8-u3Tj-K274V8qT0wg}{3OGNrcBvS424iNK6BQwLgw}{125.39.176.88}{125.39.176.88:9300}, current {node-2}{S77O9WbzR\_Sv0R2tJXgUfQ}{doWv8sGUSOGPuvUv-uEvZA}{125.39.176.86}{125.39.176.86:9300})  
[2017-02-25T22:26:55,610][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][search][T#15]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,609][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][generic][T#3]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,609][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][refresh][T#3]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,559][WARN][i.n.u.c.SingleThreadEventExecutor] Unexpected exception from an event executor:  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,609][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][generic][T#5]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,609][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][generic][T#2]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,564][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,560][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,561][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,564][WARN][i.n.u.c.SingleThreadEventExecutor] Unexpected exception from an event executor:  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,557][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,564][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,609][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-3] fatal error in thread [elasticsearch[node-3][generic][T#1]], exiting  
java.lang.OutOfMemoryError: Java heap space  
[2017-02-25T22:26:55,557][WARN][i.n.c.n.NioEventLoop] Unexpected exception in the selector loop.  
java.lang.OutOfMemoryError: Java heap space

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 26, 2017, 8:38am UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483/2 "2017-02-26T08:38:45Z")

</div>

How many nodes, how many indices/shards/GB of data.

> [@blair319](#):
>
> -XX:+UseG1GC

We do not support G1GC.

---

<div class="post-metadata">

### Author: ![blair319](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@blair319](https://discuss.elastic.co/u/blair319)
#### Post date: [February 26, 2017, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483/3 "2017-02-26T10:19:13Z")

</div>

{  
"\_nodes": {  
"total": 4,  
"successful": 4,  
"failed": 0  
},  
"cluster\_name": "xxxx",  
"nodes": {  
"S77O9WbzR\_Sv0R2tJXgUfQ": {  
"timestamp": 1488103776255,  
"name": "node-2",  
"transport\_address": "xxxx:xxx",  
"indices": {  
"docs": {  
"count": 127359010,  
"deleted": 0  
},  
"store": {  
"size\_in\_bytes": 44671418610,  
"throttle\_time\_in\_millis": 0  
},  
"indexing": {  
"index\_total": 41720888,  
"index\_time\_in\_millis": 13529348,  
"index\_current": 2,  
"index\_failed": 0,  
"delete\_total": 0,  
"delete\_time\_in\_millis": 0,  
"delete\_current": 0,  
"noop\_update\_total": 0,  
"is\_throttled": false,  
"throttle\_time\_in\_millis": 0  
},  
"get": {  
"total": 0,  
"time\_in\_millis": 0,  
"exists\_total": 0,  
"exists\_time\_in\_millis": 0,  
"missing\_total": 0,  
"missing\_time\_in\_millis": 0,  
"current": 0  
},  
"search": {  
"open\_contexts": 0,  
"query\_total": 13173,  
"query\_time\_in\_millis": 1221,  
"query\_current": 0,  
"fetch\_total": 13173,  
"fetch\_time\_in\_millis": 839,  
"fetch\_current": 0,  
"scroll\_total": 0,  
"scroll\_time\_in\_millis": 0,  
"scroll\_current": 0,  
"suggest\_total": 0,  
"suggest\_time\_in\_millis": 0,  
"suggest\_current": 0  
},  
"merges": {  
"current": 0,  
"current\_docs": 0,  
"current\_size\_in\_bytes": 0,  
"total": 11736,  
"total\_time\_in\_millis": 12061877,  
"total\_docs": 192034822,  
"total\_size\_in\_bytes": 80859329628,  
"total\_stopped\_time\_in\_millis": 0,  
"total\_throttled\_time\_in\_millis": 3719974,  
"total\_auto\_throttle\_in\_bytes": 199076943  
},  
"refresh": {  
"total": 107198,  
"total\_time\_in\_millis": 3128729,  
"listeners": 0  
},  
"flush": {  
"total": 41,  
"total\_time\_in\_millis": 14658  
},  
"warmer": {  
"current": 0,  
"total": 107251,  
"total\_time\_in\_millis": 33921  
},  
"query\_cache": {  
"memory\_size\_in\_bytes": 0,  
"total\_count": 0,  
"hit\_count": 0,  
"miss\_count": 0,  
"cache\_size": 0,  
"cache\_count": 0,  
"evictions": 0  
},  
"segments": {  
"count": 228,  
"memory\_in\_bytes": 137908043,  
"terms\_memory\_in\_bytes": 123399455,  
"stored\_fields\_memory\_in\_bytes": 12278768,  
"term\_vectors\_memory\_in\_bytes": 0,  
"norms\_memory\_in\_bytes": 188416,  
"points\_memory\_in\_bytes": 1481044,  
"doc\_values\_memory\_in\_bytes": 560360,  
"index\_writer\_memory\_in\_bytes": 6080360,  
"version\_map\_memory\_in\_bytes": 104650,  
"fixed\_bit\_set\_memory\_in\_bytes": 0,  
"max\_unsafe\_auto\_id\_timestamp": 1488067301360,  
"file\_sizes": {}  
},  
"translog": {  
"operations": 2937300,  
"size\_in\_bytes": 1573732542  
},  
"request\_cache": {  
"memory\_size\_in\_bytes": 0,  
"evictions": 0,  
"hit\_count": 0,  
"miss\_count": 0  
},  
"recovery": {  
"current\_as\_source": 0,  
"current\_as\_target": 0,  
"throttle\_time\_in\_millis": 596351  
}  
},  
"os": {  
"timestamp": 1488103776378,  
"cpu": {  
"percent": 3,  
"load\_average": {  
"1m": 0.86,  
"5m": 0.95,  
"15m": 0.92  
}  
},  
"mem": {  
"total\_in\_bytes": 33651437568,  
"free\_in\_bytes": 202268672,  
"used\_in\_bytes": 33449168896,  
"free\_percent": 1,  
"used\_percent": 99  
},  
"swap": {  
"total\_in\_bytes": 67108855808,  
"free\_in\_bytes": 52870606848,  
"used\_in\_bytes": 14238248960  
}  
},  
"process": {  
"timestamp": 1488103776379,  
"open\_file\_descriptors": 635,  
"max\_file\_descriptors": 65536,  
"cpu": {  
"percent": 3,  
"total\_in\_millis": 27088000  
},  
"mem": {  
"total\_virtual\_in\_bytes": 79897645056  
}  
},  
"jvm": {  
"timestamp": 1488103776379,  
"uptime\_in\_millis": 67822496,  
"mem": {  
"heap\_used\_in\_bytes": 5326138248,  
"heap\_used\_percent": 24,  
"heap\_committed\_in\_bytes": 21474836480,  
"heap\_max\_in\_bytes": 21474836480,  
"non\_heap\_used\_in\_bytes": 106772416,  
"non\_heap\_committed\_in\_bytes": 113504256,  
"pools": {  
"young": {  
"used\_in\_bytes": 2357198848,  
"max\_in\_bytes": 0,  
"peak\_used\_in\_bytes": 12876513280,  
"peak\_max\_in\_bytes": 0  
},  
"survivor": {  
"used\_in\_bytes": 33554432,  
"max\_in\_bytes": 0,  
"peak\_used\_in\_bytes": 318767104,  
"peak\_max\_in\_bytes": 0  
},  
"old": {  
"used\_in\_bytes": 2935384968,  
"max\_in\_bytes": 21474836480,  
"peak\_used\_in\_bytes": 2935384968,  
"peak\_max\_in\_bytes": 21474836480  
}  
}  
},  
"threads": {  
"count": 171,  
"peak\_count": 175  
},  
"gc": {  
"collectors": {  
"young": {  
"collection\_count": 375,  
"collection\_time\_in\_millis": 12972  
},  
"old": {  
"collection\_count": 0,  
"collection\_time\_in\_millis": 0  
}  
}  
},

---

<div class="post-metadata">

### Author: ![blair319](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@blair319](https://discuss.elastic.co/u/blair319)
#### Post date: [February 26, 2017, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483/4 "2017-02-26T10:19:46Z")

</div>

"buffer\_pools": {  
"direct": {  
"count": 157,  
"used\_in\_bytes": 837149048,  
"total\_capacity\_in\_bytes": 837149047  
},  
"mapped": {  
"count": 344,  
"used\_in\_bytes": 41997719220,  
"total\_capacity\_in\_bytes": 41997719220  
}  
},  
"classes": {  
"current\_loaded\_count": 10785,  
"total\_loaded\_count": 10785,  
"total\_unloaded\_count": 0  
}  
},  
"thread\_pool": {  
"bulk": {  
"threads": 24,  
"queue": 0,  
"active": 2,  
"rejected": 0,  
"largest": 24,  
"completed": 124761  
},  
"fetch\_shard\_started": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"fetch\_shard\_store": {  
"threads": 1,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 12,  
"completed": 19  
},  
"flush": {  
"threads": 1,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 2,  
"completed": 43  
},  
"force\_merge": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"generic": {  
"threads": 6,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 6,  
"completed": 124107  
},  
"get": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"index": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"listener": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"management": {  
"threads": 3,  
"queue": 0,  
"active": 1,  
"rejected": 0,  
"largest": 3,  
"completed": 31539  
},  
"refresh": {  
"threads": 4,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 4,  
"completed": 207089  
},  
"search": {  
"threads": 37,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 37,  
"completed": 13173  
},  
"snapshot": {  
"threads": 0,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 0,  
"completed": 0  
},  
"warmer": {  
"threads": 2,  
"queue": 0,  
"active": 0,  
"rejected": 0,  
"largest": 2,  
"completed": 107250  
}  
},  
"fs": {  
"timestamp": 1488103776380,  
"total": {  
"total\_in\_bytes": 1114021974016,  
"free\_in\_bytes": 972529090560,  
"available\_in\_bytes": 915940016128,  
"spins": "true"  
},  
"data": [  
{  
"path": "/home/elk/server/soft/elasticsearch-5.2.0/data/nodes/0",  
"mount": "/ (/dev/sda3)",  
"type": "ext4",  
"total\_in\_bytes": 1114021974016,  
"free\_in\_bytes": 972529090560,  
"available\_in\_bytes": 915940016128,  
"spins": "true"  
}  
],  
"io\_stats": {  
"devices": [  
{  
"device\_name": "sda3",  
"operations": 2569456,  
"read\_operations": 217856,  
"write\_operations": 2351600,  
"read\_kilobytes": 13513832,  
"write\_kilobytes": 132245960  
}  
],  
"total": {  
"operations": 2569456,  
"read\_operations": 217856,  
"write\_operations": 2351600,  
"read\_kilobytes": 13513832,  
"write\_kilobytes": 132245960  
}  
}  
},  
"transport": {  
"server\_open": 39,  
"rx\_count": 414484,  
"rx\_size\_in\_bytes": 52822731962,  
"tx\_count": 414481,  
"tx\_size\_in\_bytes": 18530101416  
},  
"breakers": {  
"request": {  
"limit\_size\_in\_bytes": 12884901888,  
"limit\_size": "12gb",  
"estimated\_size\_in\_bytes": 0,  
"estimated\_size": "0b",  
"overhead": 1,  
"tripped": 0  
},  
"fielddata": {  
"limit\_size\_in\_bytes": 12884901888,  
"limit\_size": "12gb",  
"estimated\_size\_in\_bytes": 0,  
"estimated\_size": "0b",  
"overhead": 1.03,  
"tripped": 0  
},  
"in\_flight\_requests": {  
"limit\_size\_in\_bytes": 21474836480,  
"limit\_size": "20gb",  
"estimated\_size\_in\_bytes": 778574,  
"estimated\_size": "760.3kb",  
"overhead": 1,  
"tripped": 0  
},  
"parent": {  
"limit\_size\_in\_bytes": 15032385536,  
"limit\_size": "14gb",  
"estimated\_size\_in\_bytes": 778574,  
"estimated\_size": "760.3kb",  
"overhead": 1,  
"tripped": 0  
}  
},  
},

---

<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: [March 26, 2017, 10:19am UTC](https://discuss.elastic.co/t/elasticsearch-5-2-0-java-lang-outofmemoryerror-java-heap-space/76483/5 "2017-03-26T10:19:46Z")

</div>

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