Most operating systems try to use as much memory as possible for file system
caches and eagerly swap out unused application memory. This can result in
parts of the JVM heap being swapped out to disk.
Swapping is very bad for performance and for node stability and should be
avoided at all costs. It can cause garbage collections to last for **minutes**
instead of milliseconds and can cause nodes to respond slowly or even to
disconnect from the cluster.
There are three approaches to disabling swapping:
[[mlockall]]
==== Enable `bootstrap.mlockall`
The first option is to use
http://opengroup.org/onlinepubs/007908799/xsh/mlockall.html[mlockall] on Linux/Unix systems, or https://msdn.microsoft.com/en-us/library/windows/desktop/aa366895%28v=vs.85%29.aspx[VirtualLock] on Windows, to
try to lock the process address space into RAM, preventing any Elasticsearch
memory from being swapped out. This can be done, by adding this line
to the `config/elasticsearch.yml` file:
[source,yaml]
--------------
bootstrap.mlockall: true
--------------
WARNING: `mlockall` might cause the JVM or shell session to exit if it tries
to allocate more memory than is available!
After starting Elasticsearch, you can see whether this setting was applied
successfully by checking the value of `mlockall` in the output from this