Visual VM for monitoring Java memory, CPU, threads, etc
VisualVM is a visual tool integrating several command line JDK tools and lightweight profiling capabilities. Designed for both production and development time use, it further enhances the capability of monitoring and performance analysis for the Java SE platform. It is packaged as an exe file. \
Step 1: You can start the visual vm by double clicking on %JAVA_HOME%/bin/jvisualvm.exe from Java 1.6 version on wards.
Step 2: Your local processes will be monitored under the local tab. The Visual vm can also used to open the heap dump files i.e *.hprof files to analyze the menory usages. You can find out the process ids of your local Java applications via
1. netstat -anp | grep 8088 or
2. In windows via the "Windows Task Manager" --> Processes tab. You need to click on View --> Select Columns and then "tick" PID (Process Identifier) check box.
Double click on the relevant PID in Visual VM console.
You can add remote processes by following the steps shown below.
1. Right click on "Remote" and then select "Add Remote Host...".
2. Provide the host name like "myapp.com".
3. It searches and adds the host.
4. Right click on the added host name and then select "Add JMX Connection" and in the "Connection" field type the hostname:JMX port number like myapp.com:8083.
5. Double click on this JMX connection to monitor CPU, memory, thread, etc.