The best way to set the memory is to set the ES_HEAP_SIZE parameter, and let that dictate the min and max values.
For Ubuntu just open the elasticsearch file in /etc/default:
sudo vim /etc/default/elasticsearch
and make sure that the following line is either set or uncommented, and set it to half of your total ram:
ES_HEAP_SIZE=4g
Then save your file, and restart elasticsearch:
sudo service elasticsearch restart
For more info on setting the heap size you can check out this article here. Granted the guide tells you to just create an environmental variable using the export command; however, that did not work for me, though the /etc/default/elasticsearch file will work, even after a restart.
Note: do not set the heap size over 32Gb. Using decimals for your heap_size will break Elasticsearch. If you need to use partial Gb's then use Mb like this: ES_HEAP_SIZE=3750m
. Works like a charm.