# How to check ES\_HEAP\_SIZE

**URL:** <https://discuss.elastic.co/t/how-to-check-es-heap-size/36613>\
**Category:** Elasticsearch\
**Created:** [December 8, 2015, 9:07am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613 "2015-12-08T09:07:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpong](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpong](https://discuss.elastic.co/u/gpong)\
**Post date:** [December 8, 2015, 9:07am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/1 "2015-12-08T09:07:07Z")

</div>

Hi guys,

I tried to setting ES\_HEAP\_SIZE to 1024m on my linux server. I used this setting \> export ES\_HEAP\_SIZE=1024m. Now how to check if this new setting is work??

Thanks

---

<div class="post-metadata">

**Author:** ![justnj](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@justnj](https://discuss.elastic.co/u/justnj)\
**Post date:** [December 8, 2015, 9:24am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/2 "2015-12-08T09:24:12Z")

</div>

check echo $ES\_HEAP\_SIZE

---

<div class="post-metadata">

**Author:** ![justnj](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@justnj](https://discuss.elastic.co/u/justnj)\
**Post date:** [December 8, 2015, 9:25am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/3 "2015-12-08T09:25:00Z")

</div>

> [@gpong](#):
>
> used this setting \> export ES\_HEAP\_SIZE=1024m. Now how to check if this new setting is work??

set it in elasticsearch.yml of config file

---

<div class="post-metadata">

**Author:** ![gpong](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpong](https://discuss.elastic.co/u/gpong)\
**Post date:** [December 8, 2015, 9:28am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/4 "2015-12-08T09:28:13Z")

</div>

What do you mean by setting es\_heap\_size on config file?? I read on the elasticsearch website that es\_heap\_size is an environment variable. and how to setting it to config file?? ES\_HEAP\_SIZE : 1024m like this??

Thanks

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 8, 2015, 9:40am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/5 "2015-12-08T09:40:53Z")

</div>

> I tried to setting ES\_HEAP\_SIZE to 1024m on my linux server. I used this setting \> export ES\_HEAP\_SIZE=1024m. Now how to check if this new setting is work??

Look at the resulting JVM process when you start ES, specifically the -Xmx option.

If you're starting ES as a service (which you should be doing) you should probably be modifying /etc/sysconfig/elasticsearch or /etc/default/elasticsearch instead.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [December 8, 2015, 3:35pm UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/6 "2015-12-08T15:35:20Z")

</div>

> [@gpong](#):
>
> I tried to setting ES\_HEAP\_SIZE to 1024m on my linux server. I used this setting \> export ES\_HEAP\_SIZE=1024m. Now how to check if this new setting is work??

Both Elasticsearch and the JVM provides some wonderful introspection tools, so there are many ways to check this.

- Query the endpoint `/_nodes/stats/jvm` and for each node inspect the path `jvm.mem.heap_max_in_bytes`. For example, if I start Elasticsearch with `ES_HEAP_SIZE=4g` listening on localhost and then execute

```auto
curl -sS -XGET localhost:9200/_nodes/stats/jvm | jq '..|.heap_max_in_bytes?|select(type != "null")'

```

I see

```auto
4225236992

```

- Similarly, you can use the cat nodes API by executing

```auto
curl -sS -XGET "localhost:9200/_cat/nodes?h=heap*&v"

```

which would give

```auto
heap.current heap.percent heap.max 
     119.9mb 2 3.9gb 

```

with the same 4g heap.

on the console. If you have multiple nodes running, this will print out one line for each node.

- You can use jps to see the command line flags. For example, if I start Elasticsearch with `ES_HEAP_SIZE=4g` and then execute

```auto
jps -l -m -v

```

then I see

```auto
5858 org.elasticsearch.bootstrap.eElasticsearche start -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/Users/jason/elasticsearch/elasticsearch-2.1.0

```

- Another good tool to know is `jinfo`. For example:

```auto
jinfo -flags 5858

```

gives

```auto
Attaching to process ID 5858, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.66-b17
Non-default VM flags: -XX:CICompilerCount=4 -XX:CMSInitiatingOccupancyFraction=75 -XX:+DisableExplicitGC -XX:+HeapDumpOnOutOfMemoryError -XX:InitialHeapSize=4294967296 -XX:MaxHeapSize=4294967296 -XX:MaxNewSize=697892864 -XX:MaxTenuringThreshold=6 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=697892864 -XX:OldPLABSize=16 -XX:OldSize=3597074432 -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseFastUnorderedTimeStamps -XX:+UseParNewGC 
Command line: -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/Users/jason/elasticsearch/elasticsearch-2.1.0

```

Note the `-XX:InitialHeapSize=4294967296 -XX:MaxHeapSize=4294967296` in the output.

There are many other ways to check this same information (JVisualVM, Java Mission Control, `jstat`, `jmap`, etc.).

---

<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:** [December 10, 2015, 4:11am UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/7 "2015-12-10T04:11:14Z")

</div>

That won't work though! See @magnusbaeck's response.

---

<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 5, 2017, 11:32pm UTC](https://discuss.elastic.co/t/how-to-check-es-heap-size/36613/8 "2017-07-05T23:32:09Z")

</div>


