Useful command to know about, if you have the JDK (Java 6 update 7 or newer) installed. In the bin directory of the JDK, there is a tool called jvisualvm, to launch it, run the command
VisualVM allows to troubleshoot and profile a java application, the official guide here. JVisualVM is really handy, it has options to grab the memory/cpu snapshots and you get graphs of CPU and heap dump usage. It also has menu option called “Compare Memory Snapshots” where you can compare the visualvm memory snapshots.
Another useful command to know about, (again in the bin directory of the jdk) is jmap which you can use to get heap dumps to analyse.
Where: “live” means get only information about the live objects. “b” is specifying the dump to a binary file.
To troubleshoot memory problems, it maybe worthwhile to take a couple of heapdumps periodically so that can see what’s changing between the dumps.
The tool that I’ve used to inspect heap dumps is MAT, it has quite nice UI.
Good luck in your troubleshooting!