# Possibility to limit memory usage of MMap FS?

**URL:** https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908
**Category:** Elasticsearch
**Created:** [July 5, 2015, 8:11am UTC](https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908 "2015-07-05T08:11:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rmeindl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmeindl/32/3578_2.png) [@rmeindl](https://discuss.elastic.co/u/rmeindl)
#### Post date: [July 5, 2015, 8:11am UTC](https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908/1 "2015-07-05T08:11:36Z")

</div>

ES is using hybrid MMap/NIO FS as default. Downside of this setup is that on our nodes ES (1.5.2) only leaves ~300 MB free for the operating system (Ubuntu 14.04.2) ... is there a way to limit the Off-Heap memory footprint used by Lucene or is the only way to control it re-indexing to pure NIO FS (hard, because large index but possible because SSDs used for storage). I have also not found what percentage of memory MMap leaves unused ... always around 300-350 MB which sometimes is causing troubles for the OS ...

---

<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: [July 5, 2015, 8:59am UTC](https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908/2 "2015-07-05T08:59:41Z")

</div>

Use `-XX:MaxDirectMemorySize` JVM directive with a limit to trigger garbage collection on off-heap memory.

[https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html)

Note, please check `elasticsearch.in.sh` to remove/comment the line

`JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"`

since `-XX:+DisableExplicitGC` avoids any garbage collection calls to release off-heap memory.

---

<div class="post-metadata">

### Author: ![rmeindl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmeindl/32/3578_2.png) [@rmeindl](https://discuss.elastic.co/u/rmeindl)
#### Post date: [July 5, 2015, 10:31am UTC](https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908/3 "2015-07-05T10:31:10Z")

</div>

Thanks, will try it. `ES_DIRECT_SIZE` I have found too, the `-XX:+DisableExplicitGC` I would have overlooked.

---

<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, 12:03am UTC](https://discuss.elastic.co/t/possibility-to-limit-memory-usage-of-mmap-fs/24908/4 "2017-07-06T00:03:34Z")

</div>


