# Java heapspace issue while running logstash

**URL:** <https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601>\
**Category:** Logstash\
**Created:** [May 27, 2020, 6:29pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601 "2020-05-27T18:29:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [May 27, 2020, 6:29pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/1 "2020-05-27T18:29:28Z")

</div>

Hi All,

I'm using logstash to ingest data into elasticsearch, while executing logstash its throwing up java heap space error.  
There is almost 5450 documents i'm trying to ingest. Any ideas or suggestions where i should look into for this error?

```
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/cronline.rb:77: warning: constant ::Fixnum is deprecated
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 2048k 100 2048k 0 0 737k 0 0:00:02 0:00:02 --:--:-- 737k
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid2962.hprof ...
Heap dump file created [2845468074 bytes in 2.787 secs]
warning: thread "[main]>worker2" terminated with exception (report_on_exception is true):
java.lang.OutOfMemoryError: Java heap space
        at org.jruby.RubyString.doClone(org/jruby/RubyString.java:1344)
        at org.logstash.Cloner.deep(org/logstash/Cloner.java:25)
        at org.logstash.Cloner.deepMap(org/logstash/Cloner.java:65)
        at org.logstash.Cloner.deep(org/logstash/Cloner.java:21)
        at org.logstash.Event.clone(org/logstash/Event.java:320)
        at org.logstash.ext.JrubyEventExtLibrary$RubyEvent.clone(org/logstash/ext/JrubyEventExtLibrary.java:149)
        at org.logstash.ext.JrubyEventExtLibrary$RubyEvent.clone(org/logstash/ext/JrubyEventExtLibrary.java:144)
        at java.lang.invoke.DirectMethodHandle$Holder.invokeSpecial(java/lang/invoke/DirectMethodHandle$Holder)
        at java.lang.invoke.LambdaForm$MH/0x00000008011cc440.invoke(java/lang/invoke/LambdaForm$MH)
        at java.lang.invoke.DelegatingMethodHandle$Holder.delegate(java/lang/invoke/DelegatingMethodHandle$Holder)
        at java.lang.invoke.LambdaForm$MH/0x00000008011c3040.guard(java/lang/invoke/LambdaForm$MH)
        at java.lang.invoke.DelegatingMethodHandle$Holder.delegate(java/lang/invoke/DelegatingMethodHandle$Holder)
        at java.lang.invoke.LambdaForm$MH/0x00000008011c3040.guard(java/lang/invoke/LambdaForm$MH)
        at java.lang.invoke.Invokers$Holder.linkToCallSite(java/lang/invoke/Invokers$Holder)
        at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_filter_minus_split_minus_3_dot_1_dot_8.lib.logstash.filters.split.filter(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-split-3.1.8/lib/logstash/filters/split.rb:89)
        at java.lang.invoke.DirectMethodHandle$Holder.invokeStatic(java/lang/invoke/DirectMethodHandle$Holder)
        at java.lang.invoke.LambdaForm$MH/0x0000000801da9040.invoke(java/lang/invoke/LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/0x0000000800bd6840.invokeExact_MT(java/lang/invoke/LambdaForm$MH)
        at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1814)
        at org.jruby.RubyArray$INVOKER$i$0$0$each.call(org/jruby/RubyArray$INVOKER$i$0$0$each.gen)
        at java.lang.invoke.LambdaForm$DMH/0x0000000801171840.invokeVirtual(java/lang/invoke/LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$MH/0x00000008011e0040.invoke(java/lang/invoke/LambdaForm$MH)
        at java.lang.invoke.Invokers$Holder.linkToCallSite(java/lang/invoke/Invokers$Holder)
        at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_filter_minus_split_minus_3_dot_1_dot_8.lib.logstash.filters.split.filter(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-split-3.1.8/lib/logstash/filters/split.rb:85)
[2020-05-27T18:30:09,611][ERROR][org.logstash.Logstash] java.lang.OutOfMemoryError: Java heap space

```

I'm using exec plugin to run curl and get data.

Thanks  
Gautham

---

<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:** [May 27, 2020, 6:53pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/2 "2020-05-27T18:53:24Z")

</div>

What does your filter configuration look like? Are you splitting an array?

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [May 27, 2020, 7:31pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/3 "2020-05-27T19:31:42Z")

</div>

@Badger i have 3 different filters configured,

```
filter
       {
         json { source => "message" }
         split { field => "results" }
       prune { blacklist_names => ["command", "host", "message"] }
} 

```

This is my document,

```
"results": [
        {
            "IPAddress": "1.9.7.2",
            "Caption": "APPV1",
            "NodeID": 1,
            "DNS": "appv1.global.com",
            "Vendor": "Windows",
            "Location": "",
            "MachineType": "Windows 2016 Server",
            "StatusDescription": "Node status is Up, One or more application monitors is Down, Intel(R) 82574L Gigabit Network Connection #2 · eth2 is in an Unknown state, One or more AppInsight for IIS monitors is in an Unknown state.",
            "Status": 1,
            "Severity": 5001,
            "TotalMemory": 6.871887E+10,
            "PercentMemoryUsed": 30,
            "CPUCount": 25,
            "CPULoad": 28,
            "LastBoot": "2020-05-26T14:25:00.0000000",
            "StatusLED": "Up.gif "
        },

```

If i try to ingest 2000 documents its working, when the count goes above 2000 then its throwing error.

Thanks  
Gautham

---

<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:** [May 27, 2020, 7:49pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/4 "2020-05-27T19:49:12Z")

</div>

Read this [post](https://discuss.elastic.co/t/how-to-split-into-multiple-events-dynamically-for-a-given-json-tried-from-various-question-in-forums/167745/10). The rest of that thread provides background and explanation.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [May 27, 2020, 8:51pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/5 "2020-05-27T20:51:00Z")

</div>

@Badger Perfectly explained and it worked like a charm.. Thank you very much.

Thanks  
Gautham

---

<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:** [June 24, 2020, 8:51pm UTC](https://discuss.elastic.co/t/java-heapspace-issue-while-running-logstash/234601/6 "2020-06-24T20:51:09Z")

</div>

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