# I want to recreate the java heap memory issue which is happening in production

**URL:** <https://discuss.elastic.co/t/i-want-to-recreate-the-java-heap-memory-issue-which-is-happening-in-production/370616>\
**Category:** Logstash\
**Created:** [November 15, 2024, 4:42pm UTC](https://discuss.elastic.co/t/i-want-to-recreate-the-java-heap-memory-issue-which-is-happening-in-production/370616 "2024-11-15T16:42:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devops\_training](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devops_training/32/131845_2.png) [@devops\_training](https://discuss.elastic.co/u/devops_training)\
**Post date:** [November 15, 2024, 4:42pm UTC](https://discuss.elastic.co/t/i-want-to-recreate-the-java-heap-memory-issue-which-is-happening-in-production/370616/1 "2024-11-15T16:42:18Z")

</div>

Testing in windows instance  
C:\monitoring\logstash\logstash-8.15.1\config\jvm.options  
Change the below parameters

## JVM configuration

# Xms represents the initial size of total heap space

# Xmx represents the maximum size of total heap space

jvm.options file

```auto
-Xms64m
-Xmx64m

```

Below is the configuration for generating logs continuously

```auto
                input {
  generator {
    lines => [
      "Test log message 1: INFO - test event 12234 #123",
      "Test log message 2: WARN - Data batch #123 missing some fields",
      "Test log message 3: ERROR - Failed to process data batch #123"
    ]
    count => -1      
   
  }
}

filter {
  mutate {
    add_field => { "generated_at" => "%{@timestamp}" }
  }
}

output {
  stdout {
    codec => "rubydebug"
  }
}

```

Almost the generated logs are run for 8 +hours ingesting log events in 1000+ but could not recreate the issue.

I understand that I can increase the heap memory size but I need this to approve from my team for approval.

Initially I had 1G as heap memory , to recreate I downsized the memory 64M.

Please advise

---

<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:** [November 15, 2024, 5:01pm UTC](https://discuss.elastic.co/t/i-want-to-recreate-the-java-heap-memory-issue-which-is-happening-in-production/370616/2 "2024-11-15T17:01:02Z")

</div>

If you want to recreate a memory leak from another environment then you will have to know what is causing the memory leak. To do that you will need heap dumps from the production JVM when it runs out of memory.

Just running logstash with a generator input is unlikely to trigger any memory leaks.

---

<div class="post-metadata">

**Author:** ![devops\_training](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devops_training/32/131845_2.png) [@devops\_training](https://discuss.elastic.co/u/devops_training)\
**Post date:** [November 17, 2024, 11:14am UTC](https://discuss.elastic.co/t/i-want-to-recreate-the-java-heap-memory-issue-which-is-happening-in-production/370616/3 "2024-11-17T11:14:10Z")

</div>

Complete error from logstash-plain.log

```auto
[2024-11-15T13:27:44,917][ERROR][logstash.outputs.elasticsearch][main][6a5094c9605622b56a8d911c2d0dd9dee27197919122ff10ebef00b8ff978a27] Encountered a retryable error (will retry with exponential backoff) {:code=>503, :url=>"https:// ********************************* :443/_bulk", :content_length=>4514}
[2024-11-15T19:35:45,263][FATAL][org.logstash.Logstash] uncaught error (in thread pool-348-thread-1)
java.lang.OutOfMemoryError: Java heap space
[2024-11-15T19:35:45,811][FATAL][org.logstash.Logstash][main][20d507e6459bc4bdb2ebc74148b31fcb57cc2469f5a0a520f54dcfd4176ccb85] uncaught error (in thread [main]<file)
java.lang.OutOfMemoryError: Java heap space

[2024-11-14T13:10:03,688][ERROR][logstash.outputs.elasticsearch][main][6a5094c9605622b56a8d911c2d0dd9dee27197919122ff10ebef00b8ff978a27] Encountered a retryable error (will retry with exponential backoff) {:code=>503, :url=>" *****************************", :content_length=>20052}
[2024-11-14T22:39:23,361][INFO][logstash.javapipeline][main] Pipeline terminated {"pipeline.id"=>"main"}

```

Please advise. Should I increase java heap memory or reduce bulk index size
