How to collect performance data with VisualVM and JMX

  • Updated


Remote monitoring and collection of performance data using JMX and VisualVM for a Java environment.


1. Either on the problematic system or on a remote system install the VisualVM software for data collection. 

VisualVM is an app for Windows/Mac/Linux:

2. For the Java environment being monitored.  The following JVM properties are needed (more information on these can be found here). Make sure to add these BEFORE the javaagent: <not needed in most cases>
-Djava.rmi.server.hostname=<server IP address, really only needed if there are multiple Nic cards>
Note! Port 9010 will be used later when connecting to the hostname/port defined with VisualVM

The following example shows the properties along with the Java agent:

java \ \ \ \
-Djava.rmi.server.hostname= \ \
-javaagent:./contrast.jar \
-Dcontrast.config.path=contrast_security.yaml \
-jar webgoat-container-7.1-exec.jar \
-httpPort 8082

3. Start up the Application and check to ensure the 9010 port is listening. 

netstat -tupln
Note! If running remotely you may need to open up the systems firewall to allow the connection from VisualVM.

4. Launch VisualVM and add a Remote Host:


5. Then add the JMX Connection:


6. Once connected you will start seeing live threads within the JVM along with Contrast:


7. Click on the Sampler tab, then select the CPU button to start collecting data on CPU performance:


8. Recreate the performance problem while this is running.

9. Once recreated selectmceclip5.png and export the data


10. To collect Thread data select the Threads tab and select Thread Dump:


This will open a separate tab where all the text should be copied and pasted into a text document:


11. Lastly to collect details on the environment.  Right click on the Remote Host connection and select Application Snapshot:


This will show up under the snapshots menu, right click and save this:


12. At this point you should have collected the CPU snapshot, thread dump and application snapshot. These should be zipped up and sent to support.  If the resulting files are large, ask your support rep for a SendSafely link to post them to.

See also:




Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request