# Prevent Logstash/JVM from shutting down when memory usage is high

**URL:** <https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110>\
**Category:** Logstash\
**Created:** [September 11, 2017, 5:47pm UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110 "2017-09-11T17:47:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wakinov](https://avatars.discourse-cdn.com/v4/letter/w/49beb7/32.png) [@wakinov](https://discuss.elastic.co/u/wakinov)\
**Post date:** [September 11, 2017, 5:47pm UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110/1 "2017-09-11T17:47:24Z")

</div>

Besides using a buffer like Kafka or increasing the memory on the machines. Is there a way to prevent Logstash from using too much memory and shutting down. For example, have it make input plugins stop accepting new messages until it has memory to continue.

---

<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:** [September 12, 2017, 5:12am UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110/2 "2017-09-12T05:12:29Z")

</div>

How does it shutdown, can you show logs?

---

<div class="post-metadata">

**Author:** ![wakinov](https://avatars.discourse-cdn.com/v4/letter/w/49beb7/32.png) [@wakinov](https://discuss.elastic.co/u/wakinov)\
**Post date:** [September 12, 2017, 2:44pm UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110/3 "2017-09-12T14:44:05Z")

</div>

I do not have my own logs ATM. But the logs were something along the lines of:

> Error: Your application used more memory than the safety cap of 4G.  
> Specify -J-Xmx####m to increase it (#### = cap size in MB).  
> Specify -w for full OutOfMemoryError stack trace

---

<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:** [September 12, 2017, 10:42pm UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110/4 "2017-09-12T22:42:11Z")

</div>

That looks like the OS stopping Logstash, not Logstash stopping itself.

---

<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:** [October 10, 2017, 10:42pm UTC](https://discuss.elastic.co/t/prevent-logstash-jvm-from-shutting-down-when-memory-usage-is-high/100110/5 "2017-10-10T22:42:17Z")

</div>

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