In most cases, all you need to know is which classes are most to blame for chewing memory. You can use: jmap -histo against a running process, which is convenient if it's a big JVM ... you donβt want to bother with large heap dump files. It must be run as the same Linux user who owns the process, for example, on Linux you can use:
sudo -u <user> jmap -histo <pid>
Obviously, histo means histogram. This will output the histogram to stdout, so you probably want to pass it to a file for analysis. It will be sorted by number of instances * instance size, so look at the first 10 records and you may have your own answer.
source share