Tuning JRockit JVM
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Have you ever seen strange pauses in your application that you haven't been able to explain? Have you seen one or all CPUs pegged on 100% utilization and all the others on 0% and still very few transactions in your system? If you answered yes to either of these two questions, your application might have been suffering from the effects of a poorly performing garbage collector. Some fairly simple tuning of the memory management system can improve performance dramatically for many applications.
To provide the optimal out-of-the-box experience, BEA JRockit JVM comes with default values that adapt automatically to the specific platform on which you are running BEA JRockit JVM. Tuning BEA JRockit JVM is accomplished by using non-standard—or -X
—command line options that you enter at startup. -X
options are exclusive to BEA JRockit JVM. Use them to set the behavior of BEA JRockit JVM to better suit the needs of your Java applications.
This section describes how to use these options to tune BEA JRockit. It includes information on the following subjects:
Note: If BEA JRockit behaves in some unexpected way, please consult the BEA JRockit Developers FAQ. If that doesn't solve your problem, please send an e-mail to support@bea.com
System performance is greatly influenced by the size of the Java heap available to the JVM. This section describes the command line options you use to define the initial and maximum heap sizes and the size of any nursery that might be required by generational garbage collectors. It also includes key guidelines for help you determine the optimal heap size for your BEA JRockit implementation.
-Xms
sets the initial and minimum size of the heap. For this, we recommend that you set it to the same size as the maximum heap size; for example:
-java -Xgcprio:throughput -Xmx:64m
-Xms:64m
myClass
-server
mode: 25% of the amount of free physical memory in the system, up to 64 MB and a minimum of 8 MB.
-client
mode: 25% of the amount of free physical memory in the system, up to 16 MB and a minimum of 8 MB.
-Xmx:<size>
As a rule, you want to set the maximum heap size as high as possible, but not so high that it causes page faults for the application or for some other application on the same computer. Set the maximum heap size by using the -Xmx
command-line option; for example:
-java -Xgcprio:throughput
-Xmx:64m
-Xms:64m myClass
What these options configure is subject to change between releases.This depends on many things, for example your hardware platform, your operating system, and which BEA JRockit version you use. Some guidelines based upon these criteria are listed in Table 2-1.
If you encounter OutOfMemory errors, you should increase the maximum heap size according to the guidelines listed above.
-server
and -client
modes: The default value is the lesser of 75% of the total physical memory up to 1 GB.
-Xns:<size>
-Xns
sets the size of the young generation (nursery) in generational garbage collectors. Optimally, you should try to make the nursery as large as possible while still keeping the garbage collection-pause times acceptably low. This is particularly important if you are creating a lot of temporary objects.
Note: To display pause times, include the option-Xgcpause
when you start BEA JRockit JVM.
The maximum size of a nursery cannot exceed 95% of the maximum heap size.
-server
mode: the default nursery size is 10 MB per CPU; for example, the default for a ten CPU system would be 100 MB.
-client
mode: the default nursery size is 2 MB.
Additionally, the default nursery will never exceed 25% of maximum heap size, unless you use -Xns
to explicitly set it to something larger.
The following guidelines offer some hints on how best to size a heap to achieve optimal performance. Be aware that these guidelines are mainly valid for the -server (default) start-up option (see Setting the Default Garbage Collector).
-Xms
and -Xmx
to the same value.-Xms
to at least the approximate amount of live data. You can set -Xms
to as much as twice the minimum amount of live data without disturbing automatic heap resizing. If -Xmx
isn't set, or is set too low, frequent garbage collections can slow startup until BEA JRockit has grown the heap.-Xmx
higher than the amount of available physical memory in the system. Also, you must account for of the memory usage of other applications intended to run simultaneously with the JVM, as these will impact memory availability.-Xmx
at all. This will prevent BEA JRockit from growing the heap when there is too little memory in the system. Be aware that this will throw an OutOfMemoryError if object allocation fails with the current heap size and the heap cannot grow without causing paging.-Xmx
isn't set. BEA JRockit will not shrink the heap if more than half the heap is filled with live data. Thus, BEA JRockit might not always be able to shrink the heap if the amount of free memory is reduced after JRockit has been started; for example, when another application is started.-Xmx)
compared to the amount of live data can affect performance by forcing BEA JRockit to perform frequent garbage collections. If you anticipate a "tight" heap (that is, the amount of live objects is close to the size of the heap) and the application allocates many short lived objects, we suggest you use a generational garbage collector (-Xgc:gencon
) instead of a single-spaced garbage collector (-Xgc:singlecon
and -Xgc:parallel
).
-Xcleartype:<gc|local|alloc>
-Xcleartype
defines when the memory space occupied by an object that has been garbage collected will be cleared. When clearing is actually performed is specified by the selected parameter, as described in Table 2-2.
The preferable options are either alloc
or local
.
If the -XclearType
is not set, the default is alloc
on IA32 systems and local
on IA64 systems.
-Xss<size>[k|K][m|M]
-Xss<size>[k|K]
[m|M] sets the thread stack size in kilobytes.
Minimum thread stack size is 16 kilobytes. If -Xss
is set below the minimum value, thread stack size will default to the minimum value automatically.
If the thread stack size has not been set the default value depends on the platform on which BEA JRockit is running. Table 2-3 shows these defaults:
![]() ![]() |
![]() |
![]() |