$ cd $JMETER_HOME/demo

$ ../bin/run_simple_jvmagent -jar sample_program

Use the file name of the specific sample you want to run in place of sample_program.

4.In the console main window, click Connect and type in the host name of the machine that runs the sample application. If you specified a port number when starting the node agent, use the same port number. Otherwise, leave the port number box empty.

5.An icon representing the host appears in the main window. After a few moments, the console also shows the sample application as a child node of the host.

6.Double-click the application node to open a monitoring session with the application. The dialog box for setting session preferences will open.

7.Click OK to accept the default settings for metrics, filters and alerts. The console main window now displays the open session.

Memory Leak Applications

There are two sample applications ML1 and Pi, that demonstrate how memory leak alerts work in HPjmeter. ML1 demonstrates how Java Collection Leak alerts work, and Pi demonstrates how how Array Leak alerts work.

The ML1 example uses a simple Java program that allocates some objects, and uses a java.util.Vector object to retain references to some of the objects, thus exhibiting the behavior of a memory-leaking application.

This application is configured to leak memory at the rate of about 10 MB per hour. The demo application is available from the HPjmeter installation directory:

Source: $JMETER_HOME/demo/ML1.javaBinary: $JMETER_HOME/demo/ML1.jarUse —jar ML1.jar with the run_simple_jvmagent script to start the sample.

When measuring the sample applications, allow considerable time for the heap to mature and stabilize, and for the JVM agent to collect memory leak data. Eventually, you will see two alerts:

Expected Out Of Memory Error Alert (page 110) with the leaking rate.Java Collection Leak Locations Alert (page 111) with the leak location.

When using the default garbage collectors and heap size for Java HotSpot Virtual Machine 1.4.2, the detection of a memory leak for this demonstration program occurs after about 20 minutes. This time can be substantially longer when using a different JVM or non-standard garbage collector or heap settings.

In real situations, the detection time depends on the maximum heap size, the size of the leak, the application running time, and the application and load characteristics. Typically, the detection will occur in about one hour.

Here is a Java collection leak alert for the sample program:Here is the heap display for the sample program:

Monitoring Demonstration Instructions

33