Swap vs -XX:+AlwaysPreTouch

For newer elasticsearch versions... I guess v5.0 and above... I see that we have jvm.options file. In that file we have the JVM flag -XX:+AlwaysPreTouch set by default.

As I understand, this flag tells the OS to map the memory pages to the java process at the time of process initialization versus at incrementally at runtime.

As per the oracle page on jvm settings - Java HotSpot VM Options, AlwaysPreTouch does the following:

Pre-touch the Java heap during JVM initialization. Every page of the heap is thus demand-zeroed during initialization rather than incrementally during application execution

My question is:

If this flag is already set during ES startup then why do we need to turn off swap in the OS?

Does anyone from elasticsearch team know about this one? or should I be asking this on a different forum?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.