# Suggestions on how to limit ES in embedded mode on limited memory

**URL:** <https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213>\
**Category:** Elasticsearch\
**Created:** [October 14, 2015, 8:44pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213 "2015-10-14T20:44:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidl340](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@davidl340](https://discuss.elastic.co/u/davidl340)\
**Post date:** [October 14, 2015, 8:44pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/1 "2015-10-14T20:44:51Z")

</div>

I have a grails web application that has an embedded ES version 1.3.5 instance in it. It is configured like this:

```
        Settings settings = ImmutableSettings.settingsBuilder()
                .put("node.http.enabled", false)
                .put("index.gateway.type", "none")
                .put("index.number_of_shards", 1)
                .put("path.data", siIndexLoc)
                .put("index.number_of_replicas", 0).build();
        node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
        client = node.client();

```

It is embedded with a grails app that has 1 gig of heap.  
The use case is indexing a very small # of documents with very frequent updates.

The issue is this: during index time, I run out of heap (apparently) when I do lots of concurrent indexing with the bulk API with this exception:

```
Exception in thread "elasticsearch[Master Menace][[myindex][0]: Lucene Merge Thread #1]" org.apache.lucene.index.MergePolicy$MergeException: java.lang.OutOfMemoryError: Java heap space
at org.apache.lucene.index.ConcurrentMergeScheduler.handleMergeException(ConcurrentMergeScheduler.java:545)
at org.elasticsearch.index.merge.scheduler.ConcurrentMergeSchedulerProvider$CustomConcurrentMergeScheduler.handleMergeException(ConcurrentMergeSchedulerProvider.java:134)

```

I have read the docs about limiting memory but it all seems to be geared towards standalone setups by setting 'ES\_HEAP\_SIZE'. Is there a way to limit memory usage during indexing while in embedded mode? Is my ES instance setup in an inappropriate manner?

---

<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:** [October 14, 2015, 9:02pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/2 "2015-10-14T21:02:10Z")

</div>

How much data are you indexing into it?

---

<div class="post-metadata">

**Author:** ![davidl340](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@davidl340](https://discuss.elastic.co/u/davidl340)\
**Post date:** [October 14, 2015, 9:24pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/3 "2015-10-14T21:24:58Z")

</div>

Here is a paste of localhost:9200/\_stats

[http://pastebin.com/8E0Dj2wf](http://pastebin.com/8E0Dj2wf)

---

<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:** [October 14, 2015, 9:29pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/4 "2015-10-14T21:29:00Z")

</div>

So not much.  
How much heap does ES have?

---

<div class="post-metadata">

**Author:** ![davidl340](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@davidl340](https://discuss.elastic.co/u/davidl340)\
**Post date:** [October 15, 2015, 11:40am UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/5 "2015-10-15T11:40:05Z")

</div>

The JVM with grails and ES in it had 512m, it would die indexing without much effort, I bumped it up to 1024m and it is much harder to get it to run out, but I can still make it happen without a lot of effort. I'd l like for there to be some sort of safeguard against that.

---

<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:44pm UTC](https://discuss.elastic.co/t/suggestions-on-how-to-limit-es-in-embedded-mode-on-limited-memory/32213/6 "2017-07-05T23:44:38Z")

</div>


