As a JVM application, the Elasticsearch main server process only utilizes memory devoted to the JVM. The required memory may depend on the JVM used (32- or 64-bit). The memory used by JVM usually consists of:
as a Java application ElasticSearch uses memory allocated to java applications obeviously
Heap space in Java is used for dynamic memory allocation for Java objects and JRE classes at the runtime. New objects are always created in heap space and the references to this objects are stored in stack memory.
heap space are configured via -Xms and -Xmx in mbs
sudo nano /etc/elasticsearch/jvm.options
Modify the value of -Xms and -Xmx
Best practise , dont put more that 45% of your RAM
# Xms represents the initial heap space
# Xmx represents the maximum heap space
Here set values as below
-Xms256m
-Xmx256m
Now restart Elastic Search
sudo systemctl restart elasticsearch