10 Tuning for a Faster JVM Startup

This chapter describes how to tune the JVM to decrease the startup time.

Small utility applications that run only for a short time might have a degraded performance if the JVM and Java application startup time is long. The Oracle JRockit JVM is by default optimized for server use, which means that the startup times can be longer in favour of high performance as soon as the application is up and running.

This chapter includes information about the following topics:

10.1 Measuring the Startup Time

The startup time of an application is the time it takes for the application to start running, and be ready to perform its designated activities. The startup time includes both the JVM startup and the Java application startup times.

For information about how to measure the startup time of your application, see the Oracle JRockit Diagnostics and Troubleshooting Guide.

10.2 Setting the Heap Size

The heap size affects both the JVM startup time and the Java application startup time. The JVM reserves memory for the maximum heap size (-Xmx) and commits memory for the initial heap size (-Xms) at startup, which takes time. For large applications, this is inevitable. Note that using an oversized heap can lead to longer than necessary JVM startup times. If your application is small and runs for only a short time, you might have to set a small heap size to avoid the overhead of reserving and committing more memory than the application requires.

If the initial heap is too small, the Java application startup becomes slow as the JVM is forced to perform garbage collection frequently until the heap grows to a more reasonable size. For optimal startup performance, set the initial heap size to the same as the maximum heap size.

10.3 Troubleshooting Your Application and the JVM

The application can cause the slow startup. For information about troubleshooting problems in the application and JVM, see the Oracle JRockit Diagnostics and Troubleshooting Guide.