title: How to change Elasticsearch max memory size
body: <p>I have an Apache server with a default configuration of Elasticsearch and everything works perfectly, except that the default configuration has a max size of 1GB.</p>
  
  <p>I don't have such a large number of documents to store in Elasticsearch, so I want to reduce the memory.</p>
  
  <p>I have seen that I have to change the <code>-Xmx</code> parameter in the Java configuration, but I don't know how.</p>
  
  <p>I have seen I can execute this:</p>
  
  <pre><code>bin/ElasticSearch -Xmx=2G -Xms=2G
  </code></pre>
  
  <p>But when I have to restart Elasticsearch this will be lost.</p>
  
  <p>Is it possible to change max memory usage when Elasticsearch is installed as a service?</p>