VisualVM specializes in JVM monitoring and performance analysis.
Most people should have it installed with the JDK, on my machine its in :-
Otherwise if you can't find it simply go and download it here, unzip the archive to a suitable place.
You can then run VisualVM using \bin\jvisualvm.exe or \bin\visualvm.exe
Goto Tools\Plugins and first install the default plugins :-
For concurrency analysis you can get additional ThreadDumpAnalyzer plugins here.
Logfile Plugin Version 2.2
TDA Library Plugin Version 2.2
TDA VisualVM Plugin Version 2.2
TDA 2.2 Final - Optional
Use Tools\Plugins\Downloaded to install the custom plugins (*.nbm files).
After installing the plugins then restart VisualVM.
OverviewAfter starting VisualVM you see a list of running JVM processes on the left. Double clicking a process will open the main tabbed interface. The tabs allow you to investigate different aspects of your programs runtime behaviour, like memory usage, running threads, GC generations, etc.
Heap DumpYou can generate a Java heap dump by using a right click menu on the process or from a button on the Monitor tab.
You can then analyse the heap dump using VisualVM.
You can see the objects on the heap, and how much memory they use. You can find the root reference that is causing the instance to remain alive by looking in the references window.
Garbage CollectionYou can observe the garbage collector and the size of the generations using the VisualGC plugin.
ProfilerThe Profiler and Sampler tabs give basic profiling functionality.
The Profiler allows code to be instrumented and then uses this to measure how much time is spent in each method.
The ‘Sampler’ looks at the execution stack at a certain sample rate and from there infer time spent / memory used by function.
You can observe running threads in the threads inspector, these include both JVM threads like the finalizer thread as well as your own application threads.
Tracer PluginsThe ‘Tracer’-plugins allows monitoring of specific things in the VM, mostly stuff that is exposed using JMX, things like IO usage and JIT compilation.
Sure there is the excellent free jmap for statistics and heap dumps useful for triage in production, there is the Eclipse open source TPTP, then there are commerical tools like JProfiler and YourKit.
However free is hard to beat, and VisualVM is a useful tool to have in anyones toolbox!