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 to set the heap memory that will be allocated to elasticsearch java process.
We can set Environment Variable as fololows
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 is 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 repos of elastic.