Chapter 7. Tuning the Java virtual machine 219
You may think of a JVM as a special type of operating system. It requires some time to
prepare a runtime environment for execution of a Java program. It starts multiple threads,
loads multiple Java classes, and so on.
Runtime environment
The Java programming language has built-in support for multithreading. This feature implies
that JVM on iSeries has to run in a job that supports multiple threads, for example batch
immediate (BCI).
Figure 7-1 shows a simplified view of JVM. It also shows a special type of a thread called the
garbage collector. This thread is responsible for cleaning up a JVM heap.
Figure 7-1 JVM environment on iSeries
A Java program creates many objects during its execution. These objects are created in a
JVM heap. When an object is dead (meaning that no other object has a reference to this
object), garbage collector removes this object from the heap. This function of the Java
language and JVM is performed automatically.
There are two operating modes for the garbage collector:
Asynchronous: In this mode, the garbage collector tries to clean up the heap without
stopping other threads. It runs in the background.
Stop-and-copy: In this mode, all active threads are suspended while the garbage
collector cleans up the heap.
JVM on iSeries uses the asynchronous algorithm for the garbage collector. See 7.2,
“Garbage collection in iSeries JVM” on page 223, for more details about garbage collector.
7.1.2 Runtime modes of execution
Java programs can be executed in different execution modes. An execution mode is the
manner in which a JVM converts Java bytecode into the machine instructions. There are
trade-offs between these modes.
Important: JVM and Java programs create a high number of threads. Make sure that you
have an adequate setting for the activity level in the subsystem where you run JVM.
Also, the health of JVM and garbage collector plays the most important role in ensuring
good performance of your Java and WebSphere applications.
JAVA
CLASS('Hello')
Java Virtual
Machine (JVM)
Application Code
(Hello.class)
Garbage
Collector
Thread X Thread Y
Interactive Job
Batch Immediate Job

Get Maximum Performance with WebSphere Application Server V5.1 on iSeries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.