Migrating Java Applications to HP-UX

15
Java Heap Size and Garbage Collection Behavior
The behavior of the Java heap and garbage collector is critical to achieving good application
performance. Tuning the heap is easy, especially when using HPjmeter. When migrating a Java
application from another platform to HP-UX, make sure that the heap parameters are comparable to
your previous settings, and that you are using an equivalent or similar GC policy.
Garbage Collection in HP's Hotspot JVM
Basic Generational Garbage Collection in HP Hotspot
The following is a brief description of the basic garbage collector in the HP Hotspot JVM and the GC
policies supported.
The HP Hotspot JVM supports a generational garbage collector. The Java heap is divided into multiple
spaces or generations:
New Space for newly created objects
Old Space for longer-lived objects
Perm Space for reflective data or "permanent" objects
The New Space is further divided into 3 regions: eden and two survivor spaces (to and from). Newly
created objects get allocated into the eden space. When eden becomes full, a scavenge GC is
triggered. Live objects in the eden space are identified and copied into the survivor space (to), and
garbage is removed from eden. To space then becomes the from space. The process starts again,
with newly created objects going into eden and scavenge GCs getting triggered when eden is full.
Live objects are then copied from eden and from into to. After objects have survived enough
scavenges, they get migrated to old space, or tenured. The tenuring threshold determines how many
scavenges an object survives before getting migrated to old space.
Eventually, when the old space is determined to be too full, a Full GC is performed. A Full GC
collects both the new and old spaces, examining all objects in the entire heap.
Scavenge GCs are usually quick, whereas Full GC's are very time-consuming. The principle behind
generational garbage collection is that many objects in an application are short-lived and will be
garbage-collected while in the New Space. Therefore, overall GC time is reduced for the most
common case.
GC Policies Supported in HP's Hotspot
There are multiple types of garbage collectors that operate on the different subspaces of the Java
heap.
Basic "serial" collector (described in the previous section)
This collector is a single-threaded, stop-the-world collector. On the new space, a fast copying
collector is used to perform the scavenge GC. On the old space, a mark-compact copying
collector is used to perform the Full GC. The Full GC requires scanning and processing the
entire heap and is very time-consuming.
Parallel scavenge of New space (high-throughput collector)
This collector uses multiple threads to perform the scavenge GC on the New space, thereby
reducing the total stop-the-world pause time. To enable parallel scavenge, use the JVM