A good way to capture a heap dump when OOME happens is to add the VM parameter -XX:+HeapDumpOnOutOfMemoryError . You will get an HPROF heap dump that can be opened by JProfiler and other tools.
At JProfiler, the first stop to check for excessive memory consumption is the Bigger Objects view for the coachman. In many cases, it immediately becomes apparent why too much memory is being used.
source share