# Unable to set heap size via LS\_HEAP\_SIZE on logstash 5.1.1

**URL:** <https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085>\
**Category:** Logstash\
**Created:** [January 10, 2017, 1:03pm UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085 "2017-01-10T13:03:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Spadoni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_spadoni/32/14434_2.png) [@Marco\_Spadoni](https://discuss.elastic.co/u/Marco_Spadoni)\
**Post date:** [January 10, 2017, 1:03pm UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085/1 "2017-01-10T13:03:09Z")

</div>

I am currently using logstash 5.1.1 on CentOS 7 sending it into execution from a bash shell. When using logstash 2.3.4 I was able to run several instances each one with a different maximum heap size, by making use of the LS\_HEAP\_SIZE environment variable (together with --allow-env option). With 5.1.1 it seems that the variable is overridden, since all other variables (significant to the filtering stage of the pipeline) are correctly set, but the heap is not changed (examined via Java VisualVM). I am able to change the heap by editing config/jvm.options file, but this has the inconvenience that the value contained in that file is used for each started instance. Any hint is welcome, thanks.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 12, 2017, 6:13pm UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085/2 "2017-01-12T18:13:28Z")

</div>

> together with --allow-env option

`--allow-env` has nothing to do with the JVM options.

> I am able to change the heap by editing config/jvm.options file, but this has the inconvenience that the value contained in that file is used for each started instance.

Perhaps this thread is useful:

> [@Setting jvm.options with multiple logstash (5.x) instances on the same box](https://discuss.elastic.co/t/setting-jvm-options-with-multiple-logstash-5-x-instances-on-the-same-box/67765):
>
> Hi all, we recently started looking into deploying multiple instances of logstash on the same box and noticed that when the logstash settings directory is changed from the default (/etc/logstash), the jvm.options file is no longer read. For example in our current setup we have: /etc/logstash/instance1/(logstash.yml, jvm.options etc) /etc/logstash/instance2/(logstash.yml, jvm.options etc) and jvm.options is not detected. If we move jvm.options back in /etc/logstash/ then it's read as normal…

---

<div class="post-metadata">

**Author:** ![fh8510](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@fh8510](https://discuss.elastic.co/u/fh8510)\
**Post date:** [January 13, 2017, 1:05am UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085/3 "2017-01-13T01:05:38Z")

</div>

You can set the heap size via environment variable, LS\_JAVA\_OPTS

I use the following in our startup script.  
export LS\_JAVA\_OPTS=" -Xmx4g -Xms4g"

From first few lines of bin/logstash scrip, see line 13:

```
$ cat -n bin/logstash

     1 #!/bin/sh
     2 # Run logstash from source
     3 #
     4 # This is most useful when done from a git checkout.
     5 #
     6 # Usage:
     7 # bin/logstash <command> [arguments]
     8 #
     9 # See 'bin/logstash --help' for a list of commands.
    10 #
    11 # Supported environment variables:
    12 # LS_JVM_OPTS="xxx" path to file with JVM options
    13 # LS_JAVA_OPTS="xxx" to append extra options to the defaults JAVA_OPTS provided by logstash
    14 # JAVA_OPTS="xxx" to *completely override* the defauls set of JAVA_OPTS provided by logstash

```

This works for me. Hope that helps.

---

<div class="post-metadata">

**Author:** ![Marco\_Spadoni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_spadoni/32/14434_2.png) [@Marco\_Spadoni](https://discuss.elastic.co/u/Marco_Spadoni)\
**Post date:** [January 13, 2017, 9:06am UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085/4 "2017-01-13T09:06:36Z")

</div>

> [@fh8510](#):
>
> LS\_JAVA\_OPTS=" -Xmx4g -Xms4g"

It works!  
Many thanks to you and also to Magnus.  
Marco

---

<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:** [February 10, 2017, 9:06am UTC](https://discuss.elastic.co/t/unable-to-set-heap-size-via-ls-heap-size-on-logstash-5-1-1/71085/5 "2017-02-10T09:06:53Z")

</div>

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