User Guide
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Memory management relies on effective "garbage collection," the process of clearing dead objects from the heap, thus releasing that space for new objects. Effective memory management ensures efficient processing. BEA JRockit's unified garbage collector allows you to select a dynamic garbage collector based solely upon one of two priorities: memory throughput or duration of pause time caused by collection. The unified garbage collector is dynamic in that, as it runs, it uses predefined heuristics to determine which collection algorithm to use and changing that algorithm as the individual case might warrant. You do not need to specify the actual algorithm to run this garbage collector.
In some instances, dynamic garbage collection might not be the most effective way to free-up memory. In those cases, BEA JRockit also provides a number of "static" collectors that can be started either by specifying the actual collector (-Xgc:<
collectorName
>
) or by default, as determined by the JVM mode you select at startup.
This section describes how to use all of these garbage collection methods. It contains information on the following subjects:
The unified garbage collector is a mark-and-sweep collector that runs either as generational or single-spaced; that is, with or without a "nursery" (see Generational, below). Both mark-and-sweep options can implement either a concurrent or parallel algorithm. Please refer to Garbage Collector Permutations for more information on garbage collection options and algorithms.
A mark-and-sweep collector is a three-pass model that frees all unreferenced objects. It works as described in these steps:
The unified garbage collector is comprised of various permutations—or "states"—of two garbage collector options:
and two garbage collection algorithms:
In generational garbage collection, the heap is divided into two sections: an old generation and a young generation—also called the "nursery." Objects are allocated in the nursery and when it is full, the JVM "stops-the-world" (that is, stops all threads) and moves the live objects in the young generation into the old generation. At the same time, an old collector thread runs in the background, marking live objects in the old generation and removing the dead objects, returning free space to JVM.
The single-spaced option of garbage collection means that all objects live out their lives in a single space on the heap, regardless of their age. In other words, a single-spaced garbage collector does not have a nursery.
The concurrent garbage collection algorithm does its marking and/or sweeping "concurrently" with all other processing; that is, it does not stop Java threads to do the complete garbage collection.
The parallel garbage collection algorithm stops Java threads when the heap is full and uses every CPU to perform a complete mark and/or sweep of the entire heap. A parallel collector can have longer pause times than concurrent collectors, but it maximizes throughput. Even on single CPU machines, this maximized performance makes parallel the recommended garbage collector, provided that your application can tolerate the longer pause times.
The unified garbage collector combines the options and algorithms described above within the mark-and-sweep model to perform collection. Depending upon the heuristics used, the collector will employ a generational or single-spaced collector with either a concurrent or parallel mark phase and a concurrent or parallel sweep phase.
The main benefit of a dynamic—or "optimizing"—garbage collector is that the only determination you need to make to run the collector best-suited to your needs is whether your application responds best to optimal memory throughput during collection or minimized pause times at that time. You do not need to understand the garbage collection algorithms themselves, or the various permutations thereof, just the behavior of your application.
Note: -Xgcprio
is not supported on BEA JRockit releases 1.4.2_08 and earlier. It is supported on releases 1.4.2_10 and later.
To start the unified garbage collector, use the -Xgcprio
command line option with either the throughput
or pausetime
parameter, depending upon which priority you want to use:
-Xgcprio:<throughput|pausetime>
Table 3-1 describes the priorities under which you can start a dynamic garbage collector and the parameters used to select that priority.
Upon selecting the priority and starting the JVM, the dynamic garbage collector will then try to choose the garbage collection state that optimizes performance based upon the priority. It will seek modes that optimize throughput when -Xgcprio:throughput
is set or that minimize the pause times (as much as possible) when -Xgcprio:pausetime
is set.
In some circumstances, you might not want to use a dynamic garbage collector. In those cases, you can use a static collector started by default or by selecting one of the backwardly-compatible garbage collectors provided in earlier versions of BEA JRockit. Unlike the dynamic garbage collector started with -Xgcprio
, static collectors do not change from the algorithm originally selected to collect garbage. They will not attempt to optimize performance by changing algorithms.
This section contains information on the following subjects:
Three static garbage collectors originally available in earlier versions of BEA JRockit SDK are still available for your use in this version. In some circumstances, the performance of these collectors might meet your needs better than the unified collector or the default collectors available with the -server
or -client
flags. Additionally, if you want to use scripts written for the earlier versions of BEA JRockit that implement these collectors, those scripts will continue to work without requiring any modification—unless they use the generational copy garbage collector, which is no longer available (of course, your scripts can be modified to implement the unified garbage collector).
The available garbage collectors (and the command to start them) are:
-Xgc:singlecon
; this is the default garbage collector when BEA JRockit is run in the -client
mode)-Xgc:gencon
)-Xgc:parallel
; this is the default garbage collector in the -server
mode)Table 3-2 lists the pros and cons of each garbage collector.
Table 3-3 is a matrix that you can use to determine which garbage collector is right for your BEA JRockit JVM implementation. Use the If... column to locate a condition that matches your implementation and select the garbage collector indicated in the Select this Garbage Collector... column. The third column lists the supported garbage collector that might suit your needs as well as—if not better than—an unsupported collector.
If you don't set -Xgcprio
or -Xgc
at startup, BEA JRockit defaults to a preselected, static garbage collector based upon the JVM mode you select: server-side (-server
; the default) or client-side (-client
). These are not garbage collectors themselves, but JVM configuration options that start a static collector and set default initial and maximum heap sizes. Table 3-4 describes how these startup options set a garbage collector.
By definition, BEA JRockit is a server-side JVM, thus the |
|
When you start BEA JRockit in the |
For more information on using the -server
and -client
options, please refer to Starting and Configuring BEA JRockit JVM.
Setting -Xgcprio
will override any settings associated with -server
and -client
. Setting -Xgc
will override -Xgcprio
and -server
and -client
.
To observe garbage collection activity, use one or both of the options described here. Using these options will help you evaluate the effectiveness of the selected garbage collector and make necessary tuning decisions.
-Xgcreport
option at startup. This option causes BEA JRockit JVM to print a comprehensive garbage collection report at program completion. -Xgcpause
option.This option causes the VM to print a line each time Java threads are stopped for garbage collection.Combining these two options is a very good way of examining the memory behavior of your application; for example:
-java -Xgcreport -Xgcpause myClass
Thread-local allocation removes object allocation contention and reduces the need to synchronize between threads allocating memory on the heap. It also increases cache performance on a multi-CPU system, because it reduces the risk of two threads running on different CPUs needing to access the same memory pages at the same time.
Thread-local allocation is not the same thing as thread-local objects, but many people tend to confuse the two terms. Thread-local allocation does not determine whether the objects can be accessed from a single thread only (that is, thread-local objects); thread-local allocation means that the thread has an area of its own where no other thread will create new objects. The objects that the thread creates in that area may still be reached from other threads.
![]() ![]() |
![]() |
![]() |