# Elasticsearch off-heap memory

**URL:** <https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416>\
**Category:** Elasticsearch\
**Created:** [May 19, 2017, 11:59am UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416 "2017-05-19T11:59:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteelCrow](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@SteelCrow](https://discuss.elastic.co/u/SteelCrow)\
**Post date:** [May 19, 2017, 11:59am UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416/1 "2017-05-19T11:59:52Z")

</div>

Hi, guys!

I have some problem with memory consumption, I jope you will help me with it.

OS: RHEL 7.3  
Elasticsearch 5.4  
RAM: 8GB (real 7.6GB)  
Clear install of EL  
Nothing in index  
Nothing else run on machine  
Nothing request EL

JVM Heap set to 4GB  
swap off  
all descriptors, threads tuning by EL guide

And I meet something strange as for me

```
* ps -eo pid,ppid,cmd,comm=,rss,vsz,%mem,%cpu --sort=-%mem | head

PID PPID CMD RSS VSZ %MEM %CPU
46433 1 /bin/java -Xms4g -Xmx4g -XX java 4661496 6906888 58.2 0.2

```

VSZ show that virt memory consumption is ~6.5GB

```
* free -m

         total used free shared buff/cache available
Mem: 7815 4575 837 96 2401 2697

```

Show that only ~4.5GB is used

```
* curl -X GET '127.0.0.1:9200/_cat/nodes?v&h=id,ip,port,v,m,ram.current,ram.percent,ram.max'

id ip port v m ram.current ram.percent ram.max
aRwE 10.48.5.59 9300 5.4.0 * 6.8gb 89 7.6gb

```

EL think it use about ~6.8GB (89%MEM)

```
* top

KiB Mem : 65.6/8002828 
KiB Swap: 0.0/2097148 

  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
46433 elastic+ 20 0 6906888 4.447g 125296 S 0.0 58.3 0:40.56 java

```

Top said that ~6.8GB (58.3%MEM) but from simple math 6.8GB/7.6GB \* 100% = 89% (like in EL request)

Where the truth? EL virt memory include some buff/cash from system? If it isn't true, why that much memory consumption (~4gb HEAP) + 2.5 GB [for what?], if no index and data...

---

<div class="post-metadata">

**Author:** ![droberts195](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/droberts195/32/17692_2.png) [@droberts195](https://discuss.elastic.co/u/droberts195)\
**Post date:** [May 19, 2017, 12:27pm UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416/2 "2017-05-19T12:27:38Z")

</div>

Does it help if you set the environment variable `MALLOC_ARENA_MAX=2` before starting Elasticsearch? (Don't set this in the environment you use to run non-Java programs - try to limit it just to Java programs. There's more background [here](https://info.prelert.com/blog/java-8-and-virtual-memory-on-linux).)

---

<div class="post-metadata">

**Author:** ![SteelCrow](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@SteelCrow](https://discuss.elastic.co/u/SteelCrow)\
**Post date:** [May 19, 2017, 1:40pm UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416/3 "2017-05-19T13:40:09Z")

</div>

Thank you droberts195, I understood what's going on much clearer. But, does changing MALLOC\_ARENA\_MAX is a good choice if I have only ELK stack on machine? I thought Kibana is not Java app, am I wrong?

---

<div class="post-metadata">

**Author:** ![droberts195](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/droberts195/32/17692_2.png) [@droberts195](https://discuss.elastic.co/u/droberts195)\
**Post date:** [May 19, 2017, 1:44pm UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416/4 "2017-05-19T13:44:58Z")

</div>

That's right, Kibana is not a Java program, so do not set `MALLOC_ARENA_MAX` when you run it. Each program has different environment variables, so (assuming it helps with your problem) you want to set `MALLOC_ARENA_MAX=2` when starting Elasticsearch but _not_ when starting Kibana. The exact way to do this will depend on how you start these programs.

---

<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 16, 2017, 1:45pm UTC](https://discuss.elastic.co/t/elasticsearch-off-heap-memory/86416/5 "2017-06-16T13:45:23Z")

</div>

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