Out of memory exception under high load

Which version of Logstash are you using? Are you using the grok filter?

I have seen reports of a memory leak within the grok filter, which I believe has been fixed in version 4.0.3 of this filter. You can check which version of the plugin you are using through the following command: bin/logstash-plugin list --verbose

If you are on an older version, you can update that plugin and see if that makes a difference.