Diagnostics Guide

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Tuning For Faster JVM Startup

Small utility applications that run only for a short time may suffer a performance hit 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 section describes how to tune the JVM to decrease the startup times, covering the following topics:


Measuring the Startup Time

The startup time of an application is the time it takes for the application to get up and running and ready to start doing what it is supposed to do. The startup time includes both the JVM startup and the Java application startup.

For information on how to measure the startup time of your application, see Timing with nanoTime() and currentTimeMillis().


Setting the Heap Size

The heap size has an impact on 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, but you should be aware that using an oversized heap may lead to longer JVM startup times than necessary. If your application is small and runs only for a short time you may have to set a small heap size to avoid the overhead of reserving and committing more memory than the application will ever need.

On the other hand, 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 has grown to a more reasonable size. For optimal startup performance you should set the initial heap size to the same as the maximum heap size.


Troubleshoot Your Application and the JVM

The application itself may be causing the startup to become slow. See The Oracle JRockit JVM Starts Slowly for tips on troubleshooting problems in the application and JVM.

  Back to Top       Previous  Next