Search code examples
javaperformancejvmjvm-hotspot

Does AlwaysPretouch cause to touch pages within -Xms or -Xmx?


There is a maximum memory java heap can use (as configured by -Xmx) and initial java heap size (-Xms).

How does -XX:+AlwaysPretouch play with them. Does it pretouch memory upto -Xms or -Xmx. e.g. when java is started with -Xmx=8G -Xms=4G -XX:+AlwaysPretouch, will its resident set be roughly 4G or 8G?

If this matters, i am interested in what happens on Linux and on java 7 and 9.


Solution

  • Xms (4G).

    AlwaysPreTouch affects committed memory only. When the heap increases, JVM pretouches only new committed pages.