# What occupies my heap

**URL:** <https://discuss.elastic.co/t/what-occupies-my-heap/75637>\
**Category:** Elasticsearch\
**Created:** [February 19, 2017, 12:35pm UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637 "2017-02-19T12:35:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [February 19, 2017, 12:35pm UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/1 "2017-02-19T12:35:52Z")

</div>

Hi guys,

ES 2.3.5 here. We use 50GB RAM nodes with heap size set to 50% + mlockall on openjdk 1.8.0\_92.  
I'm trying to figure out what occupies the heap.

I'm looking at the node stats of one of the data nodes and see that the used heap size is 18GB and I'm trying to understand what exactly it copmrises from. So far I see:

- fielddata - 6GB
- segments.memory - 1.5GB
- segments.terms\_memory - 1.3GB

These together are less than 10GB. All of the other memory related values I could find are less than 100MB, and I wonder where did the other ~9GB has gone?

The full cluster state is [here](http://pastebin.com/24NA6ssC).

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [February 26, 2017, 8:26am UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/2 "2017-02-26T08:26:57Z")

</div>

Anyone, please?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 27, 2017, 9:45am UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/3 "2017-02-27T09:45:14Z")

</div>

Hey,

you can check under the `jvm` section how much heap is in use - if this always much less than you configured, it makes sense to reduce the heap. This way the free memory can also be used by the file system cache for faster searches.

--Alex

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [February 27, 2017, 11:58am UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/4 "2017-02-27T11:58:42Z")

</div>

Hi Alexander,

That's not what I'm trying to find out - my heap is 71% full and that's not the problem, What I would like to understand is what consumes it.  
JVM section shows that majority of the memory is under `old` section. Again, I've checked fielddata size, segments, etc. and it just does not add up to the heap size.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 27, 2017, 2:53pm UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/5 "2017-02-27T14:53:16Z")

</div>

hey,

you forgot the query cache (which is also in the stats), memory per thread, parent child, global ordinals, and many small contributed factors (script caches, many other simple caching structures). if you need to break it down, the simplest thing would be to take a heap dump and analyze that one, as not everything is easy to monitor and returned in the node stats - for example the data structures to create aggregations per request are not displayed, as they are short lived (however in more recent releases there is a circuit breaker for this).

--Alex

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [February 27, 2017, 2:54pm UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/6 "2017-02-27T14:54:34Z")

</div>

I see. Do you know if there is a walkthough on such a heap analysis?

---

<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 27, 2017, 2:54pm UTC](https://discuss.elastic.co/t/what-occupies-my-heap/75637/7 "2017-03-27T14:54:37Z")

</div>

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