# How to decrease memory footprint of ElasticSearch

**URL:** <https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542>\
**Category:** Elasticsearch\
**Created:** [November 4, 2012, 12:02am UTC](https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542 "2012-11-04T00:02:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axsuul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axsuul/32/2663_2.png) [@Axsuul](https://discuss.elastic.co/u/Axsuul)\
**Post date:** [November 4, 2012, 12:02am UTC](https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542/1 "2012-11-04T00:02:13Z")

</div>

Is it me or does ElasticSearch require a hefty memory footprint even at its  
bare minimum? Currently, I have it at

-Xms32 -Xmx32

and it shows that it's using 380m RES. I tried changing it to 16 but it  
wouldn't even run. I'm trying to use it for a small project of mine on a  
low-memory VPS. Can anyone recommend how to decrease the memory to around  
something reasonable like 100m.

--

---

<div class="post-metadata">

**Author:** ![Artem\_Grinblat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artem_grinblat/32/2327_2.png) [@Artem\_Grinblat](https://discuss.elastic.co/u/Artem_Grinblat)\
**Post date:** [November 4, 2012, 11:51pm UTC](https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542/2 "2012-11-04T23:51:24Z")

</div>

Those resident bits might be the memory-mapped indexes. Try configuring  
ElasticSearch to use niofs[http://www.elasticsearch.org/guide/reference/index-modules/store.html](http://www.elasticsearch.org/guide/reference/index-modules/store.html)explicitly. Use soft  
or weak caches[http://www.elasticsearch.org/guide/reference/index-modules/cache.html](http://www.elasticsearch.org/guide/reference/index-modules/cache.html).  
Install bigdesk plugin[http://www.elasticsearch.org/guide/reference/modules/plugins.html](http://www.elasticsearch.org/guide/reference/modules/plugins.html),  
maybe it will help with figuring out the memory usage. Keep in mind that  
JVM needs a lot of RAM for the JIT compiler and the compiled machine code,  
try running ElasticSearch with -Xint[http://www.herongyang.com/JVM/Micro-Benchmark-Interpreted-Only-Mode.html](http://www.herongyang.com/JVM/Micro-Benchmark-Interpreted-Only-Mode.html)  
.

--

---

<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:** [November 5, 2012, 8:57am UTC](https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542/3 "2012-11-05T08:57:59Z")

</div>

Hi,

the total process space size can't be limited by -Xms or -Xmx, as they  
control only the heap space.

There is no way to prevent a JVM to stay within a process limit, as it must  
load objects into the process space. With NIO, the NIO buffers outside of  
the heap are accounted for process space.

To get the smallest footprint, try the following

- disable all plugins
- create a $HOME/.elasticsearch.in.sh file with your custom JVM params
- use -d32 for 32-bit JVM (disabling niofs and using simplefs is a natural  
consequence of 32bit)
- use -Xms64m -Xmx64m -Xss192k (128k for JDK 6), that is the lowest JVM  
start parameters I know that are safe
- disable all other extra JVM settings in elasticsearch.in.sh (comment them  
out)
- tune settings in config/elasticsearch.yml: set shards = 1, set replica =  
0, set all thread pools to max size 1, set segment tuning to lowest values  
(you have to experiment, around 1m for segment size should work)
- tune your API usage, do not use caches for facets or for filters, do not  
use warming
- check memory footprint with the cluster state API

There is a price you pay, performance will be low and the maximum data  
volume too, and the risk of OOM is high.

There are many JVMs out there beside the standard JVM of Oracle which are  
targeted at small embedded systems. But, unfortunately, without hacking the  
ES source (and the dependencies), it won't be possible to get ES running on  
other JVMs.

Jörg

On Monday, November 5, 2012 12:51:24 AM UTC+1, Artem Grinblat wrote:

> Those resident bits might be the memory-mapped indexes. Try configuring  
> Elasticsearch to use niofs[http://www.elasticsearch.org/guide/reference/index-modules/store.html](http://www.elasticsearch.org/guide/reference/index-modules/store.html)explicitly. Use soft  
> or weak caches[http://www.elasticsearch.org/guide/reference/index-modules/cache.html](http://www.elasticsearch.org/guide/reference/index-modules/cache.html).  
> Install bigdesk plugin[http://www.elasticsearch.org/guide/reference/modules/plugins.html](http://www.elasticsearch.org/guide/reference/modules/plugins.html),  
> maybe it will help with figuring out the memory usage. Keep in mind that  
> JVM needs a lot of RAM for the JIT compiler and the compiled machine code,  
> try running Elasticsearch with -Xint[http://www.herongyang.com/JVM/Micro-Benchmark-Interpreted-Only-Mode.html](http://www.herongyang.com/JVM/Micro-Benchmark-Interpreted-Only-Mode.html)  
> .

--

---

<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, 3:06am UTC](https://discuss.elastic.co/t/how-to-decrease-memory-footprint-of-elasticsearch/9542/4 "2017-07-06T03:06:12Z")

</div>


