Alternative to jstack and jmap

Jstack is being used to create a dump of threads in order to retrieve locks and to inspect running processes. Jmap is used for creating a memory dump. But there are new releases like the Server JRE which do not include none of these tools.

Administrators might wonder how to create a thread or memory dump. There is one tool to fit them all (You remember, there is that one ring to rule them all?). It is jcmd which is typically located within the 'bin' directory.

List all Java Threads

Invoke jcmd without any parameters


Dump Java Threads

jcmd [PID] Thread.print > [FILE]

Dump Java Heap/Memory

Invoke it with an absolute path (e.g. /home/userX/heap_dump) otherwise the dump might be located within the directory of the dumped app.

jcmd [PID] GC.heap_dump [PATH]

Leave a Comment

comments powered by Disqus