Where to set Heap memory - jvm.options or /etc/sysconfig/elasticsearch

I know that heap memory has to be set in jvm.options file.
-Xms2g
-Xms2g

But I can see in /etc/sysconfig/elasticsearch file also we can set heap memory.

Heap Size (defaults to 256m min, 1g max)

#ES_HEAP_SIZE=2g

Which is the correct place to set heap memory for ES?

Prefer jvm.options.

See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

Thanks...So we should prefer to set heap memory in jvm.options.
But consider the case, if someone by mistake has configured in both places and in jvm.options he mentioned 4g heap size but in env variable in elasticsearch file he mentioned ES_HEAP_SIZE=2g..

Then which one will be effective? 4g or 2g?

I don't know. Try it and look what elasticsearch reports.

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