Elasticsearch has an option to configure the memory which is used by elasticsearch java process.
The memory can be configured using various Environmental Variables.
The default Heap Size of an elasticsearch process in 1gb. The ES_HEAP_SIZE environment variable allows setting the heap memory that will be allocated to elasticsearch java process.
We can set Environment Variable as follows
We can check allocated memory using service manager of elasticsearch as follows
And another option is to lock the process address space into RAM, preventing any Elasticsearch memory from being swapped out by configuring as follows in Elasticsearch configuration file (config/elasticsearch.yml)
We can check whether settings are applied to the nodes or not by using any one of the following commands
Elasticsearch is having some minor issue in locking the memory(using Virtual lock) in Windows OS; there is already an open issue raised in Github repository of elastic.