Profile Image
vishnupriya

What is JVM startup parameter: -XX:+AlwaysPreTouch?

What is JVM startup parameter: -XX:+AlwaysPreTouch? Have you used this JVM arguement before?What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-alwayspretouchmainclass

  • x-alwayspretouchmainclass

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:                                                    

 

The option “-XX:+AlwaysPreTouch” enables touching of every page on the Java heap during JVM initialization.

 

Since:

 

Starting from JDK 6.

 

Syntax:

 

java -XX:+AlwaysPreTouch MainClass

 

Description:

 

Before discussing about the flag, we should understand how the JVM set its virtual memory. When you run the JVM, you are setting its heap size with the parameters -Xmx and -Xms. At that time, the Operating System (OS) reserve only the virtual memory. Except if the JVM wants to use the memory, then the OS physical memory will be allocated. Thus, the flag “AlwaysPreTouch” comes in handy, when enabling it, it allows the physical memory to be allocated to the JVM instead of the virtual memory. it forces all freshly committed pages to be pre-touched. This gets all pages into memory before entering the “main()” method. It speeds up the performance of the application, but nothing is perfect, it has some disadvantages. Basically, allocating physical memory to the JVM at startup will affect the JVM startup’s time and cause it to decrease.

 

The option can be used in testing to simulate a long-running system with all virtual memory mapped to physical memory.

 

Default Value:

 

By default, this option is disabled and all pages are committed as JVM heap space fills.

 

Errors:

 

None.

 

Related Posts:

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-alwayspretouchmainclass

  • x-alwayspretouchmainclass

  • JVM startup parameter