# Logastash Exec plugin Cannot allocate memory

**URL:** <https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561>\
**Category:** Logstash\
**Created:** [September 7, 2021, 4:30pm UTC](https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561 "2021-09-07T16:30:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikasgurlinka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikasgurlinka/32/79183_2.png) [@vikasgurlinka](https://discuss.elastic.co/u/vikasgurlinka)\
**Post date:** [September 7, 2021, 4:30pm UTC](https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561/1 "2021-09-07T16:30:38Z")

</div>

I am running Logstash 7.9.1 with 24 GB of maximum heap size configured in a Linux machine with 30 GB Memory and configured a pipeline to run a python program with Logstash exec plugin I see the below error message in logs.

`Error while running command {:command=>"/usr/bin/python3 /opt/logstash/config/sql.py", :e=>#<Errno::ENOMEM: Cannot allocate memory - /usr/bin/python3>,`

I did observe total JVM utilization is less than 15 GB. Below is my Logstash input configuration

```auto
input {
  exec {
    command => "/usr/bin/python3 /opt/logstash/config/sql.py"
    interval => 180

  }
}

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 7, 2021, 5:23pm UTC](https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561/2 "2021-09-07T17:23:08Z")

</div>

If you use an exec plugin then the logstash JVM will fork. That creates a copy of the JVM's memory (excluding most shared memory segments). That means that on a 30GB server you will struggle to have the JVM memory be larger than 14 GB, so I would suggest a heap size of 12 GB at most. If you still get ENOMEM at 12 GB then keep reducing the heap size.

---

<div class="post-metadata">

**Author:** ![vikasgurlinka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikasgurlinka/32/79183_2.png) [@vikasgurlinka](https://discuss.elastic.co/u/vikasgurlinka)\
**Post date:** [September 7, 2021, 6:28pm UTC](https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561/3 "2021-09-07T18:28:31Z")

</div>

@Badger Thanks for your quick reply issue got resolved after configuring the maximum JVM heap to 14 GB.

---

<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 5, 2021, 6:28pm UTC](https://discuss.elastic.co/t/logastash-exec-plugin-cannot-allocate-memory/283561/4 "2021-10-05T18:28:50Z")

</div>

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