# Logstash won't start due to memory heap issue

**URL:** <https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069>\
**Category:** Logstash\
**Created:** [September 4, 2024, 8:15pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069 "2024-09-04T20:15:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carolina\_Molina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carolina_molina/32/137326_2.png) [@Carolina\_Molina](https://discuss.elastic.co/u/Carolina_Molina)\
**Post date:** [September 4, 2024, 8:15pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/1 "2024-09-04T20:15:44Z")

</div>

Hello,

I have a instance running logstsh 6.8.2 with Java 11.0.19 and JDK of 64Bits, I changed the filter file do add conditions and terraform logstash to the correct environment. After that logstash refused to start giving me a Invalid initial heap size -Xms2g.

I have 5G of free space on that and I don't have anyrhing running on my machine that is occupying the memory.

As of now I have tried changing the heap size to several values, obeying the fact that I have in total 7G and 5G of free space and nothing solved this issue.

I looked thru the forum and tryed the suggestions and did not fix it, what do youi guys suggest I do?

---

<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:** [September 4, 2024, 10:21pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/2 "2024-09-04T22:21:01Z")

</div>

What command line is Java being started with and exactly what error message do you get?

---

<div class="post-metadata">

**Author:** ![Carolina\_Molina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carolina_molina/32/137326_2.png) [@Carolina\_Molina](https://discuss.elastic.co/u/Carolina_Molina)\
**Post date:** [September 5, 2024, 1:25am UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/3 "2024-09-05T01:25:14Z")

</div>

Hi, I’m starting logstash using the following script:

sudo systemctl start logastash

And the error I get is:

Invalid minimal heap size Xms2g

---

<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:** [September 5, 2024, 2:12am UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/4 "2024-09-05T02:12:53Z")

</div>

> [@Carolina\_Molina](#):
>
> Invalid minimal heap size

Are you absolutely without-a-doubt 100% certain that you are running a 64-bit JVM and not a 32-bit JVM?

I suggest dropping the heap size down to 512 MB and then reviewing the logs, which should include full details of the Java version being started. It doesn't matter if you cannot run your pipeline in 512 MB, you just need to get the VM up far enough to log those details. It's OK if it crashes after logging that.

---

<div class="post-metadata">

**Author:** ![Carolina\_Molina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carolina_molina/32/137326_2.png) [@Carolina\_Molina](https://discuss.elastic.co/u/Carolina_Molina)\
**Post date:** [September 5, 2024, 10:51am UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/5 "2024-09-05T10:51:44Z")

</div>

Hi, yes. I ran the script java --version and I get the 64 Bits response.

I already did this 512 MB try and it provided me the same issue of memory heap size. No matter what value I add to the jvm options it is giving me the heap error.

The logstash plain log does't update since the memory error and the syslog keeps showing the memory heap issue for each try that I did for the memory.

I'm really lost ☹

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [September 5, 2024, 11:19am UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/6 "2024-09-05T11:19:48Z")

</div>

To add more ideas:

- make a simple .conf which has input tcp or random, nothing in filter. Something like this:

```auto
input {
  generator {
       message => "Test message"
	   count => 1 }
}
filter {
}
output {
    stdout { codec => rubydebug{} }
}

```

- Badger suggested 512 MB, however 1 GB is enough in the most cases when you have file or beats inputs without complex JSON/XML transformation. On large data set, LS with start and will notice how consumes memory and slow down processing
- Use debug/trace log for more details
- Check do you have enough memory on the host. Sometimes there is a basic configuration, 2-4 GB memory with ES and Kib

How long is the message? 1 KB, 2 KB, more? Which plugins are you using in the filter?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [September 5, 2024, 12:10pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/7 "2024-09-05T12:10:45Z")

</div>

Can you share the exact log error you are getting? Try to start it again and copy the line logs generated.

Also, share your `logstash.yml` and `jvm.options` as well.

---

<div class="post-metadata">

**Author:** ![Carolina\_Molina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carolina_molina/32/137326_2.png) [@Carolina\_Molina](https://discuss.elastic.co/u/Carolina_Molina)\
**Post date:** [September 5, 2024, 12:36pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/8 "2024-09-05T12:36:11Z")

</div>

Hi , sure here is what you asked:Sep 05 12:05:18 ip-IPsystemd[1]: Started logstash.  
Sep 04 19:53:08 ip-IPsystemd[1]: Failed to start logstash.  
Sep 04 19:53:08 ip-IPsystemd[1]: logstash.service: Failed with result 'exit-code'.  
Sep 04 19:53:08 ip-IPsystemd[1]: logstash.service: Start request repeated too quickly.  
Sep 04 19:53:08 ip-IPsystemd[1]: Stopped logstash.  
Sep 04 19:53:08 ip-IPsystemd[1]: logstash.service: Scheduled restart job, restart counter is at 5.  
Sep 04 19:53:08 ip-IPsystemd[1]: logstash.service: Service hold-off time over, scheduling restart.  
Sep 04 19:53:07 ip-IPsystemd[1]: logstash.service: Failed with result 'exit-code'.  
Sep 04 19:53:07 ip-IPsystemd[1]: logstash.service: Main process exited, code=exited, status=1/FAILURE  
Sep 04 19:53:07 ip-IPlogstash[10934]: Error: A fatal exception has occurred. Program will exit.  
Sep 04 19:53:07 ip-IPlogstash[10934]: Error: Could not create the Java Virtual Machine.  
Sep 04 19:53:07 ip-IPlogstash[10934]: Invalid initial heap size: -Xms2g  
Sep 04 19:53:07 ip-IPsystemd[1]: Started logstash.  
Sep 04 19:53:07 ip-IPsystemd[1]: Stopped logstash.  
Sep 04 19:53:07 ip-IPsystemd[1]: logstash.service: Scheduled restart job, restart counter is at 4.

logstash.yml

path.data: /var/lib/logstash  
queue.type: persisted  
path.queue: /var/logstash/queue  
queue.page\_capacity: 64mb  
queue.max\_bytes: 4096mb  
queue.checkpoint.writes: 1024  
path.logs: /var/log/logstash  
config.reload.automatic: true  
config.reload.interval: 60s  
pipeline.workers: 2  
pipeline.batch.size: 250

jmv.options file is all stardart, the only change is on the heap size:

## JVM configuration

# Xms represents the initial size of total heap space

# Xmx represents the maximum size of total heap space

-Xms2g  
-Xmx2g

################################################################

## Expert settings

################################################################

## 

## All settings below this section are considered

## expert settings. Don't tamper with them unless

Thanks

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [September 5, 2024, 8:01pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/9 "2024-09-05T20:01:51Z")

</div>

Have you checked the journal?  
`journalctl -u logstash.service -n 100`

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [September 5, 2024, 8:14pm UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/10 "2024-09-05T20:14:00Z")

</div>

Can you run `free -h` in this server and share the result?

Also, can you change `g` to `G` and test again?

```auto
-Xms2G
-Xmx2G

```

---

<div class="post-metadata">

**Author:** ![Carolina\_Molina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carolina_molina/32/137326_2.png) [@Carolina\_Molina](https://discuss.elastic.co/u/Carolina_Molina)\
**Post date:** [September 6, 2024, 11:35am UTC](https://discuss.elastic.co/t/logstash-wont-start-due-to-memory-heap-issue/366069/11 "2024-09-06T11:35:23Z")

</div>

Hi everyone, I have found what was the issue.

ran a dos2unix script on my jvm.options and fixed the issue starting logstash again.

Thank you for all the suggestions, it was very helpful
