TIL if you have decided Elasticsearch maybe shouldn't get 50% of your RAM on your local machine you can adjust it with JVM options:
$ elasticsearch_path="$(brew --prefix)/etc/elasticsearch" # Assuming a Homebrew install on a Mac
$ mkdir -p $elasticsearch_path/jvm.options.d && echo "-Xms2g\n-Xmx2g" > $elasticsearch_path/jvm.options.d/heap.options
$ unset elasticsearch_path
Then restart the server: