This section provides a tutorial example on use JRockit Management Console server and client components to collect runtime data from the JRockit JVM.
JRockit JVM Management Console has two components:
The server component, which needs to be invoked in the JVM instance
where the application program is running.
The client component, which runs independently in a separate JVM instance.
The client component has a GUI that allows you to establish a connection to
a running server component by an IP port, and display real-time information
collected from that server component.
Let's use the following simple program to see how the Management Console works:
/**
* LongWhile.java
* Copyright (c) 2002 by Dr. Herong Yang, herongyang.com
*/
class LongWhile {
public static void main(String[] a) {
Runtime rt = Runtime.getRuntime();
System.out.println(" Free memory: " + rt.freeMemory());
System.out.println("Total memory: " + rt.totalMemory());
while (true);
}
}
Compile this program with J2SDK 1.4.0_02 and run it in JRockit JVM with
the Management Console server component turned on:
\progra~1\jrockit\7.0\1.4.0\bin\java -cp .
"-Djrockit.managementserver=true" LongWhile
[JRockit] Management Server started on port 7090.
Free memory: 62665048
Total memory: 73363465
Now my sample application is running in JRockit JVM with the Management
Console server turned on ready to export information on port 7090.
Use the following command to run the JRockit Management Console client
component:
cd \progra~1\jrockit\7.0\1.4.0\console
..\bin\java -jar ManagementConsole.jar
Unfortunately, this command crashed my laptop system immediate. The crash
was so bad, that I had to remove the external power and the battery to restart
the system. This happened twice. But it worked on my desktop system. The
biggest difference of my desktop is the physical memory size: 256M (128M more
than my laptop system).
Once the console client component started, I was able to connect to my running
sample application. The UI of the client component was cool, and easy to use.
So I collected the following information about my running program:
LongWhile run time object report:
Free memory: 62665048
Total memory: 73363465
JRockit management console report:
Free memory: 41523K
Total memory: 260332K
Free heap: 60664K
Total heap: 71644K
Window 2000 task manage report:
LongWhile process memory: 14840K
JRockit console process memory: 49180K
While watching at the console window, I noticed a couple of interesting things:
The heap memory usage reported on the console matches closely to the usage
reported by the RunTime object.
A few seconds after the console started, the memory management server
component running together with my LongWhile application started to leak memory
at a rate about 10K/sec.
At the same time, the console client program was also leaking memory.
About 30 minutes later, the operating system crashed. Cold re-start was
needed to bring my system back.
I repeated the test, and got the same crash. I guess JRockit 7.0 is not good
for my system configuration.