To use a JMX client, the setup you need to do first are:
- On the Target server where JVM runs, you need to enable JMX Agent for the JVM.
- On the local machine where you want to monitor your Java application from, you need a JMX client. For this post, I chose VisualVM.
- To prevent other JMX client from accessing your JMX Agent, you want to turn on authentication when your JMX client connects to your JMX Agent.
Enable JMX Agent for JVM
- allowing the user to analyze thread execution
- the ability to profile/sample CPU and memory usage
- Download Mac OS X Application Bundle
- Double click on the downloaded VisualVM .dmg file.
- Drag VisualVM to Applications folder.
Connect to JMX Agent from VisualVM
1. Select File > Add JMX Connection ...
2. Enter <server>:<port>
3. Enter controlRole or monitorRole as user, and the corresponding <password> as set up in the jmxremote.password file
VisualVM Quick Guide
Select Monitor tab
Click Heap Dump
Access JMX Agent as controlRole also allows you analyze threads and profile CPU & memory. To learn more about profiling/sampling using VisualVM, please see this article.
To analyze garbage collection (GC)
- Tools > Plugins > Settings
- Set Update Centers URL if necessary: https://visualvm.java.net/uc/6u23/updates.xml.gz
- Click Available Plugins tab, click Reload Catalog
- Select Visual GC, then Install
- Restart VisualVM, and you will see Visual GC tab