Understanding Xms Xmx options


(fucema) #1

I'm trying to better understand the memory options for Elastic Search. I was
pretty confident until I looked at the process details recently.

I start a node using this command: bin/elasticsearch -f -Xms5g -Xmx5g

Here is the resulting process details:

elastic 32361 10.3 34.3 5696452 5602468 pts/2 SLl+ 10:59 0:04
/usr/bin/java -Xms256m -Xmx1g -Xss128k -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError
-Delasticsearch -Des.path.home=/usr/local/elastic/elasticsearch
-Des-foreground=yes -cp
:/usr/local/elastic/elasticsearch/lib/elasticsearch-0.17.2.jar:/usr/local/elastic/elasticsearch/lib/:/usr/local/elastic/elasticsearch/lib/sigar/
-Xms5g -Xmx5g org.elasticsearch.bootstrap.ElasticSearch

Is the Xms/Xmx setting defining the memory space that is allocated outside
of the jvm heap? The java executable looks like its set to -Xms256m -Xmx1g.
It looks like my command line options do not affect the java memory
parameters.

I've also tried exporting ES_MIN_MEM and ES_MAX_MEM but I don't see any
differences in the process details.


(fucema) #2

Oops I stand corrected on the last part: when I export ES_MIN/MAX_MEM
settings and start up elastic search, the java memory settings reflect the
memory settings I defined in the environment variables.

So the problem stands with the command line memory settings.

It gets a little more confusing when I set both the environment variables
ES_MIN_MEM and ES_MAX_MEM and also specify memory settings from the command
line.

export ES_MIN_MEM=2g
export ES_MAX_MEM=2g

bin/elasticsearch -f -Xms3g -Xmx3g

What is going on with the memory settings here?

Here are the process details:

elastic 5131 30.5 21.2 3557832 3461188 pts/3 SLl+ 12:01 0:02
/usr/bin/java -Xms2g -Xmx2g -Xss128k -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError
-Delasticsearch -Des.path.home=/usr/local/elastic/elasticsearch
-Des-foreground=yes -cp
:/usr/local/elastic/elasticsearch/lib/elasticsearch-0.17.2.jar:/usr/local/elastic/elasticsearch/lib/:/usr/local/elastic/elasticsearch/lib/sigar/
-Xms3g -Xmx3g org.elasticsearch.bootstrap.ElasticSearch


(Shay Banon) #3

It is being passed, check at the end of the command. The last memory
settings used are the ones that are applied, and the script makes use of
that fact. You can easily see the memory settings elasticsearch was started
with using the nodes info API.

On Wed, Jul 27, 2011 at 7:04 PM, S Lee fucema@gmail.com wrote:

Oops I stand corrected on the last part: when I export ES_MIN/MAX_MEM
settings and start up elastic search, the java memory settings reflect the
memory settings I defined in the environment variables.

So the problem stands with the command line memory settings.

It gets a little more confusing when I set both the environment variables
ES_MIN_MEM and ES_MAX_MEM and also specify memory settings from the command
line.

export ES_MIN_MEM=2g
export ES_MAX_MEM=2g

bin/elasticsearch -f -Xms3g -Xmx3g

What is going on with the memory settings here?

Here are the process details:

elastic 5131 30.5 21.2 3557832 3461188 pts/3 SLl+ 12:01 0:02
/usr/bin/java -Xms2g -Xmx2g -Xss128k -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError
-Delasticsearch -Des.path.home=/usr/local/elastic/elasticsearch
-Des-foreground=yes -cp
:/usr/local/elastic/elasticsearch/lib/elasticsearch-0.17.2.jar:/usr/local/elastic/elasticsearch/lib/:/usr/local/elastic/elasticsearch/lib/sigar/
-Xms3g -Xmx3g org.elasticsearch.bootstrap.ElasticSearch


(fucema) #4

Ok, it is a little confusing because the java binary has 2g memory settings
but the 3g settings are also listed at the end.

Starts with:
/usr/bin/java -Xms2g -Xmx2g -Xss128k ...

Ends with:
... -Xms3g -Xmx3g org.elasticsearch.bootstrap.ElasticSearch

I'll take the node api status page as gospel.


(system) #5