# What is meant by Heap in relation to ES?

**URL:** <https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031>\
**Category:** Elasticsearch\
**Created:** [March 10, 2020, 11:34pm UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031 "2020-03-10T23:34:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgelb](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rgelb](https://discuss.elastic.co/u/rgelb)\
**Post date:** [March 10, 2020, 11:34pm UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/1 "2020-03-10T23:34:24Z")

</div>

Consider the following situation: the node has 100 GB of RAM, but the ES heap size is 30 GB.

Does this mean that ES will only ever use 30 GB of RAM? And the other 70 GB will go unused?  
If not, than what how does it use the memory.

P.S. I see lots of articles on setting the correct size of the heap, but can't find anything that describes what it is and how it works in relation to ES.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2020, 1:22am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/2 "2020-03-11T01:22:37Z")

</div>

The filesystem will be also using the available memory to cache files from the disk. So memory is not wasted.

---

<div class="post-metadata">

**Author:** ![rgelb](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rgelb](https://discuss.elastic.co/u/rgelb)\
**Post date:** [March 11, 2020, 5:17pm UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/3 "2020-03-11T17:17:04Z")

</div>

@dadoonet but ES itself only ever uses the amount of RAM defined as the HEAP?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2020, 10:47pm UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/4 "2020-03-11T22:47:57Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [March 11, 2020, 11:43pm UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/5 "2020-03-11T23:43:02Z")

</div>

I think that's not quite the case. It's normal to see the Elasticsearch process using more memory than the configured heap size (usually not more than 2×). It also indirectly uses the rest of the available memory in the system via the filesystem cache. A node with 100GB of memory may well perform better than a node with 64GB of memory even though Elasticsearch's heap size is 30GB in both cases. The filesystem cache is very important. The extra memory is not wasted.

---

<div class="post-metadata">

**Author:** ![rgelb](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rgelb](https://discuss.elastic.co/u/rgelb)\
**Post date:** [March 12, 2020, 12:41am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/6 "2020-03-12T00:41:19Z")

</div>

@DavidTurner Understood. However the filesystem cache is not the function of ElasticSearch but rather a function of the underlying OS. Am I correct?

Or is ES doing something explicit to force the files into the filesystem cache?

---

<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:** [March 12, 2020, 12:53am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/7 "2020-03-12T00:53:03Z")

</div>

Thats right, it's the OS that handles it.

---

<div class="post-metadata">

**Author:** ![rgelb](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rgelb](https://discuss.elastic.co/u/rgelb)\
**Post date:** [March 12, 2020, 1:18am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/8 "2020-03-12T01:18:32Z")

</div>

Thank you fellas!

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [March 12, 2020, 8:08am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/9 "2020-03-12T08:08:49Z")

</div>

I'm not sure I understand the distinction. The OS provides the RAM that the JVM uses too, both for the heap and for everything else. Your original question was whether this extra memory was used or not, and the answer is that it is indeed used.

> [@rgelb](#):
>
> Or is ES doing something explicit to force the files into the filesystem cache?

Elasticsearch (really Lucene) puts a lot of effort into accessing files in a way that increases the chances that the data it needs is already cached, and a larger filesystem cache can make that much easier.

---

<div class="post-metadata">

**Author:** ![rgelb](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rgelb](https://discuss.elastic.co/u/rgelb)\
**Post date:** [March 13, 2020, 6:37am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/10 "2020-03-13T06:37:07Z")

</div>

David, what I mean is this. Consider the following pseudo code:

`var content = FileRead("foo.txt");`

All the application (ES) did was read the contents of the file into a variable - and RAM was allocated for the application. The OS, behind the scenes, may have placed `foo.txt` into RAM (e.g. filesystem cache) so that next time `FileRead` is called, the disk doesn't have to be accessed. That RAM isn't directly used by the application, but by the OS.

---

<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:** [April 10, 2020, 6:37am UTC](https://discuss.elastic.co/t/what-is-meant-by-heap-in-relation-to-es/223031/11 "2020-04-10T06:37:13Z")

</div>

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