1

Can anybody please tell me the difference in Java process memory size and Java heap size. Actually, I was trying to configure Elasticsearch 1.5.2 instance on a machine. Its document

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html#_environment_variables

says that I can configure maximum allowed memory for the process. I suppose this is how it's done

export JAVA_OPTS=”-Xms256m -Xmx512m”

Also, I can set ES_HEAP_SIZE environment variable to tweak max heap size (Semantics is not given). Can anybody please tell me the difference between both and how to configure (syntax to specify memory) ES_HEAP_SIZE?

TheLostMind
  • 35,966
  • 12
  • 68
  • 104
Prakhar Mishra
  • 1,586
  • 4
  • 28
  • 52
  • 3
    This seems a duplicate of this question -> http://stackoverflow.com/questions/27438429/big-difference-between-jvm-process-size-and-memory-heap-size – Vítor Martins May 26 '15 at 08:44
  • You are saying that Elasticsearch's documentation is errorneous? It says: "The most important setting for that is the -Xmx to control the maximum allowed memory for the process, and -Xms to control the minimum allocated memory for the process" – Prakhar Mishra May 26 '15 at 10:07
  • It clearly states it as **memory for the process**, not heap. If we have Elasticsearch folks here, please reply. – Prakhar Mishra May 26 '15 at 10:14

1 Answers1

3

Heap is the place to store objects created by your Java application, this is where Garbage Collection takes place, the memory used by your Java application.

The total memory consumption of the JVM process consist of more things than just the Java heap, that's why your java process memory size will be greater than max heap size. Examples:

  • Thread stacks
  • memory allocated by native code / libraries

ES_HEAP_SIZE variable will be used by elasticsearch to define Xms and Xmx to this value

see code => https://github.com/elastic/elasticsearch/blob/1d3a8ad36a5eec76a246656b098cf1f68b0989fa/bin/elasticsearch.in.sh#L11

So you need to define ES_HEAP_SIZE, before starting Elasticsearch

You can do this in /etc/default/elasticsearch for example (on Debian), using export ES_HEAP_SIZE=8g

Julien C.
  • 946
  • 8
  • 22
  • The statement in Elasticsearch documentation ("The most important setting for that is the -Xmx to control the **maximum allowed memory for the process**, and -Xms to control the **minimum allocated memory for the process**") is wrong, isn't it? As we cannot control **maximum allowed memory for the process**, can we? – Prakhar Mishra May 26 '15 at 12:27
  • yes, it's a misuse of language, you'll probably have a little bigger memory size than define by Xmx – Julien C. May 26 '15 at 12:32
  • Thank you. I will settle with ES_HEAP_SIZE, then. – Prakhar Mishra May 26 '15 at 12:38