Note to self - Java heap analysis #
As I keep searching for those URLs over and over again linking them here. When running into JVM heap issues (an out of
memory exception is a pretty sure sign, so can be the program getting slower and slower over time) there’s a few things
you can do for analysis:
Start with telling the effected JVM process to output some statistics on heap layout as
well as thread state by sending it a SIGQUIT (if you want to use the number instead - it’s 3 - avoid typing 9 instead
;) ).
More detailed insight is available via jConsole - remote setup can be a bit tricky but is well doable and
worth the effort as it gives much more detail on what is running and how memory consumption really looks
like.
For an detailed analysis take a heap dump with either jmap, jConsole or by starting the process with the
JVM option -XX:+HeapDumpOnOutOfMemoryError
. Look at it either with jhat or the IBM heap analyzer. Also netbeans offers nice support for searching for memory leaks.
On a
more general note on diagnosing java stuff see Rainer Jung’s
presentation on troubleshooting Java applications as well as Att
ila Szegedi’s presentation on JVM tuning.