# OutOfDirectMemoryError: failed in Logstash logs

**URL:** <https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145>\
**Category:** Logstash\
**Created:** [September 26, 2022, 8:37am UTC](https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145 "2022-09-26T08:37:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madurad](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@madurad](https://discuss.elastic.co/u/madurad)\
**Post date:** [September 26, 2022, 8:37am UTC](https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145/1 "2022-09-26T08:37:54Z")

</div>

Hi,  
Continuously getting OutOfDirectMemoryError: failed error on Logstash, I chekced the host memory usage and CPU all good and memory is around 60% used, but no clear idea how this issue is being happened.

In jvm.options following values has been set too,

```auto
-Xms2g
-Xmx2g

```

Any help would be greatly appreciated.

```auto
[2022-09-26T07:49:21,303][WARN][io.netty.channel.DefaultChannelPipeline] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 2097152000, max: 2112618496)
        at io.netty.util.internal.PlatformDependent.incrementMemoryCounter(PlatformDependent.java:802) ~[netty-all-4.1.65.Final.jar:4.1.65.Final]
        at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:731) ~[netty-all-4.1.65.Final.jar:4.1.65.Final]

```

Thanks.

---

<div class="post-metadata">

**Author:** ![abrx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abrx/32/43881_2.png) [@abrx](https://discuss.elastic.co/u/abrx)\
**Post date:** [September 26, 2022, 12:54pm UTC](https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145/2 "2022-09-26T12:54:45Z")

</div>

The point here is not the host memory but the one you allocated to logstash, as you got 2097152000/1024/1024/1024= **1.9Go used** of the 2 you allocated.  
You should check the [performance tunning section](https://www.elastic.co/guide/en/logstash/current/performance-troubleshooting.html) in order to learn how to monitor / improve your consumption.

---

<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 26, 2022, 4:45pm UTC](https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145/3 "2022-09-26T16:45:13Z")

</div>

It doesn't matter much what your heap size is, direct memory is not allocated from the heap.

[This](https://stackoverflow.com/questions/42651707/how-to-find-a-root-cause-of-the-following-netty-error-io-netty-util-internal-ou) SO answer might help you.

---

<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 24, 2022, 4:46pm UTC](https://discuss.elastic.co/t/outofdirectmemoryerror-failed-in-logstash-logs/315145/4 "2022-10-24T16:46:03Z")

</div>

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