# In jvm.options file pass kill -9 for killing logstash on outofmemory

**URL:** <https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414>\
**Category:** Logstash\
**Created:** [April 9, 2020, 10:56pm UTC](https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414 "2020-04-09T22:56:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunil\_Vp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunil_vp/32/66044_2.png) [@Sunil\_Vp](https://discuss.elastic.co/u/Sunil_Vp)\
**Post date:** [April 9, 2020, 10:56pm UTC](https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414/1 "2020-04-09T22:56:58Z")

</div>

Hi,

I wanted to pass `-XX:OnOutOfMemoryError=kill -9 %p`  
option to the JVM arguments of logstash. I added the same in jvm.options file, But once i add it i get:

```auto
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

```

Please suggest if above option is needed in logstash and what is the format to add it. Should it be escaped or something?

Thank You

---

<div class="post-metadata">

**Author:** ![Luca\_Belluccini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luca_belluccini/32/33239_2.png) [@Luca\_Belluccini](https://discuss.elastic.co/u/Luca_Belluccini)\
**Post date:** [April 9, 2020, 11:27pm UTC](https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414/2 "2020-04-09T23:27:35Z")

</div>

Hello @Sunil_Vp

While I would suggest you to investigate why you might get `OutOfMemory` on Logstash, I think:

- You can use `-XX:+ExitOnOutOfMemoryError`
- You can use `-XX:+CrashOnOutOfMemoryError`
- You should be able to use `-XX:OnOutOfMemoryError="kill -9 %p"`

Some explanations are available [here](https://dzone.com/articles/outofmemoryerror-related-jvm-arguments).

At the same time, the typical behavior of Logstash is to stop upon an OutOfMemory, so those parameters shouldn't be necessary.

---

<div class="post-metadata">

**Author:** ![Sunil\_Vp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunil_vp/32/66044_2.png) [@Sunil\_Vp](https://discuss.elastic.co/u/Sunil_Vp)\
**Post date:** [April 27, 2020, 7:58pm UTC](https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414/3 "2020-04-27T19:58:12Z")

</div>

Thanks a lot Luca for the reply.  
I wasn't aware that the default behaviour of logstash is to stop upon OutOfMemory.

We were trying to have a custom java plugin in logstash application, so when i tried to see the jvm arguments kill on outofmemory was missing so wanted a way to add it. Since custom code was added was thinking it was safe to add the above option.

Thanks again in advance.

---

<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:** [May 25, 2020, 7:58pm UTC](https://discuss.elastic.co/t/in-jvm-options-file-pass-kill-9-for-killing-logstash-on-outofmemory/227414/4 "2020-05-25T19:58:14Z")

</div>

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