OutOfDirectMemoryError: failed in Logstash logs

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,

-Xms2g
-Xmx2g

Any help would be greatly appreciated.

[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.

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 in order to learn how to monitor / improve your consumption.

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

This SO answer might help you.