# java.lang.OutOfMemoryError: Java heap space in Logstash

**URL:** <https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-in-logstash/260596>\
**Category:** Logstash\
**Created:** [January 9, 2021, 8:14am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-in-logstash/260596 "2021-01-09T08:14:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [January 9, 2021, 8:14am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-in-logstash/260596/1 "2021-01-09T08:14:04Z")

</div>

I have too many configuration files. I run these files together via pipelines.yml. I use these types of settings likewise below;

```auto
- pipeline.id: pipeline1
  path.config: "path_to_pipeline1"
- pipeline.id: pipeline2
  path.config: "path_to_pipeline2"
- pipeline.id: pipeline3
  path.config: "path_to_pipeline3"
  .....

```

I set JVM HeapSize as 10gb with the configuration below; (I have also tried 8gb and I have 16gb ram)

```auto
-Xms10g
-Xmx10g

```

If I run my pipelines one by one. It works perfectly but when I try to run multiple pipelines after some hours I get this error

```auto
java.lang.OutOfMemoryError: Java heap space
        at org.jruby.util.io.OpenFile.binwrite(OpenFile.java:2165)
        at org.jruby.util.io.OpenFile.fwrite(OpenFile.java:2076)
        at org.jruby.RubyIO.write(RubyIO.java:1474)
        at org.jruby.RubyIO.write(RubyIO.java:1437)
        at org.jruby.RubyIO$INVOKER$i$write.call(RubyIO$INVOKER$i$write.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:819)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:208)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:203)
        at org.jruby.RubyIO.write(RubyIO.java:2638)
        at org.jruby.RubyIO.putsSingle(RubyIO.java:2589)
        at org.jruby.RubyIO.puts1(RubyIO.java:2508)
        at org.jruby.RubyIO.puts(RubyIO.java:2481)
        at org.jruby.RubyIO$INVOKER$i$puts.call(RubyIO$INVOKER$i$puts.gen)
        at java.lang.invoke.LambdaForm$DMH/1974701110.invokeVirtual_L6_L(LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$BMH/2145760212.reinvoke(LambdaForm$BMH)
        at java.lang.invoke.LambdaForm$MH/2001112025.delegate(LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/757819744.guard(LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/2001112025.delegate(LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/757819744.guard(LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/1375297293.linkToCallSite(LambdaForm$MH)
        at home.logstash.plugins.logstash_minus_codec_minus_my_plugin.lib.logstash.codecs.my_plugin.RUBY$method$file_write$0(/home/logstash/plugins/logstash-codec-my_plugin/lib/logstash/codecs/my_plugin.rb:95)
        at java.lang.invoke.LambdaForm$DMH/369219075.invokeStatic_L7_L(LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$MH/291284958.invokeExact_MT(LambdaForm$MH)
        at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:106)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:140)
        at org.jruby.ir.targets.InvokeSite.fail(InvokeSite.java:278)
        at java.lang.invoke.LambdaForm$DMH/1974701110.invokeVirtual_L6_L(LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$BMH/592048461.reinvoke(LambdaForm$BMH)
        at java.lang.invoke.LambdaForm$MH/1375297293.linkToCallSite(LambdaForm$MH)
        at home.logstash.plugins.logstash_minus_codec_minus_my_plugin.lib.logstash.codecs.my_plugin.RUBY$method$file_write$0(/home/logstash/plugins/logstash-codec-my_plugin/lib/logstash/codecs/my_plugin.rb:95)
        at java.lang.invoke.LambdaForm$DMH/75254713.invokeStatic_L7_L(LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$MH/291284958.invokeExact_MT(LambdaForm$MH)

```

In my codec plugin I've just use simple file write in ruby

```auto
def file_write(lorem_data)
    write_to_file = File.open(@location, "w")
    write_to_file.puts lorem_data.to_s
    write_to_file.close
  end

```

Thanks for answering.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 11, 2021, 12:13am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-in-logstash/260596/2 "2021-01-11T00:13:43Z")

</div>

Let's keep this to a single topic as it makes it easier to help you, plus there's a lot of existing info in your original topic [java.lang.OutOfMemoryError: Java heap space](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space/259773/4)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 11, 2021, 12:13am UTC](https://discuss.elastic.co/t/java-lang-outofmemoryerror-java-heap-space-in-logstash/260596/3 "2021-01-11T00:13:46Z")

</div>


