Mlockall: what happens if no memory available?


(Abid Hussain) #1

Hi all,

to prevent os from swapping, it's recommended to set bootstrap.mlockall: true.

I wonder the following. What happens in situations when no memory is available anymore? Does the jvm chrash in such a case? And if so, whats the benefit in using mlockall compared to swapping?

Regards,

Abid


(Magnus Bäck) #2

The mlockall option only locks the ES JVM into RAM. The rest of the OS might still swap. If Linux completely runs out of memory it will start killing processes more or less randomly.


(Abid Hussain) #3

Ok, thanks.

So setting mlockall to true just means that the jvm memory won't be swapped, it has no effect on what happens when jvm runs out or memory as it will still crash in that case. Please correct me if I'm wrong.

Regards,

Abid


(Magnus Bäck) #4

If the application running in the JVM runs out of heap it'll obviously crash with OutOfMemoryError, but that has nothing to do with mlockall. The JVM process itself can't run out of memory once it has been locked into RAM.


(Abid Hussain) #5

Thanks for clarification.


(system) #6