# Elasticsearch is taking more memory than allocated heap when using bootstrap.mlockall: true

**URL:** <https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260>\
**Category:** Elasticsearch\
**Created:** [March 10, 2014, 8:48am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260 "2014-03-10T08:48:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 10, 2014, 8:48am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260/1 "2014-03-10T08:48:18Z")

</div>

Hi,

I’ve allocated max and min heap same with _ES\_HEAP\_SIZE=1200m_ in  
elasticsearch and using \*bootstrap.mlockall: true \*as suggested by  
elasticsearch so that process memory won’t get swapped.

But when elasticsearch I start its taking more memory than max heap  
mentioned; like 1.4g and holding the same memory. The usage is not getting  
fluctuating now, which is a good thing.

Can you please explain why its taking more memory for JVM than allocated.

--Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/98cfaf5a-4559-4b7e-80ac-816626690e49%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/98cfaf5a-4559-4b7e-80ac-816626690e49%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 10, 2014, 10:04am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260/2 "2014-03-10T10:04:50Z")

</div>

A Java JVM process takes more memory than just the heap. There are shared  
libraries / classes, stacks, buffers, etc. that add to the heap memory.

If you want to analyze the process memory, you can examine the process map  
on Linux with pmap -x

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGsmFzwn%2BCmHY\_eqhUKy%3DpEP9gv8No1%3DCdUje%2BZGAYi%3DQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGsmFzwn%2BCmHY_eqhUKy%3DpEP9gv8No1%3DCdUje%2BZGAYi%3DQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 11, 2014, 9:06am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260/3 "2014-03-11T09:06:38Z")

</div>

Hi,

Actually if I fix the ES\_MAX\_MEM with some value elasticsearch is starting  
with max of that memory usage only. But when used \*bootstrap.mlockall: true  
\*and start elasticsearch it's taking more memory than ES\_MAX\_MEM.

What I'm trying to understand if how much memory elasticsearch will occupy  
for process memory pages so that I can plan for the RAM usage.

-Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [March 11, 2014, 11:02am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260/4 "2014-03-11T11:02:23Z")

</div>

There is no connection between ES\_MAX\_MEM and bootstrap.mlockall. mlockall  
can not make the JVM taking more memory, the memory consumption is the  
same. Maybe you set mmapfs and you have seen the difference between virtual  
memory and resident memory.

The recommended setting is to reserve 50% of RAM for the heap of the JVM  
ES. The other 50% are for the Java process, buffers, and other OS  
processes. This is a rule of thumb, it depends on how you want to use the  
heap of course.

JVM memory consumption can change a lot over the lifetime of a process. You  
should set ES\_MIN\_MEM to ES\_MAX\_MEM in every case. This prevents the JVM  
from allocating and releasing large chunks of memory every once a while,  
together with high GC activity.

The best you can do to get precise numbers is to start your ES cluster for  
testing, put it under heavy load according to your workload pattern, and  
measure the system metrics. Trust only the numbers you see on your system,  
nothing else.

Jörg

On Tue, Mar 11, 2014 at 10:06 AM, Subhadip Bagui [i.bagui@gmail.com](mailto:i.bagui@gmail.com) wrote:

> Hi,
> 
> Actually if I fix the ES\_MAX\_MEM with some value elasticsearch is starting  
> with max of that memory usage only. But when used \*bootstrap.mlockall:  
> true \*and start elasticsearch it's taking more memory than ES\_MAX\_MEM.
> 
> What I'm trying to understand if how much memory elasticsearch will occupy  
> for process memory pages so that I can plan for the RAM usage.
> 
> -Subhadip
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d3f91133-8867-4d1f-a552-dfad0ab6c642%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEo7%2B-9S3de5CT%2Bx2UM\_i7QGf9ZetB508VrMfO%2Bx01TNw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEo7%2B-9S3de5CT%2Bx2UM_i7QGf9ZetB508VrMfO%2Bx01TNw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:44am UTC](https://discuss.elastic.co/t/elasticsearch-is-taking-more-memory-than-allocated-heap-when-using-bootstrap-mlockall-true/16260/5 "2017-07-06T01:44:19Z")

</div>


