How to set memory limit for ElasticSearch in Windows

Running elasticsearch on my local development machine takes up half of system memory by default. Here is instructions on how to change max memory size.

Prerequisites:
* Windows 10
* This instruction is for Elasticsearch version 7.16.2 but probably works on other versions as well
* Running elasticsearch.bat (in development mode not as a service)

Goto folder:
“C:\elasticsearch\elasticsearch-7.16.2\config\jvm.options.d\”
Create file:
“jvm.options” (normal text file, utf-8)
Setting for maximum of 4GB memory allocation:

-Xms4g
-Xmx4g

Change both “4” values into other value if desired.
Restart elasticservice.bat

Instructions if running elasticsearch as a service on Windows:

You can set the memory limit for Elastic Search on Windows Server by following command:

[Elasticsearch Path]\bin>elasticsearch-service.bat manager

Note: Run command prompt as administrator

It will open manager as shown here: Image: ElasticSearch service properties

Now go to the ‘Java’ tab and change settings based on your requirement.

Note: Make sure, you changed it under ‘JavaOptions’ textbox and also for separate parameters. For example, to set 1GB initial memory pool and maximum memory pool, you can set ‘1024’ MB for both.

From: https://stackoverflow.com/questions/28798845/how-to-set-memory-limit-to-elasticsearch-in-windows