These include:
- jps
- jstat
- jinfo
- jstack
- jmap
- jhat
Let's have a look at what these tools can do.
This tool displays all of the JVM running on your host
jps -v
13397 Jps -Dapplication.home=/data/Tools/jdk1.6.0_26 -Xms8m
11170 smartsvn.jar -XX:-UseSSE42Intrinsics -Dsun.io.useCanonCaches=false ...
9762 Main -Djdk.home=/data/Tools/jdk1.6.0_26 -Dnetbeans.system_http_proxy=...
This tool displays JVM information mostly about memory
jstat -gcutil 9762
0.00 6.03 41.22 72.27 75.29 57 6.608 6 4.599 11.206
This example shows various data on garbage collection.
jinfoPerfect tool to see general information on JVM
jinfo 9762
Debugger attached successfully.
Server compiler detected.
JVM version is 20.1-b02
Java System Properties:
java.vendor = Sun Microsystems Inc.
netbeans.user = /home/andy/.netbeans/dev
...
plugin.manager.check.updates = false
VM Flags:
-Djdk.home=/data/Tools/jdk1.6.0_26 -Dnetbeans.system_http_proxy=DIRECT
...
-XX:HeapDumpPath=/home/andy/.netbeans/dev/var/log/heapdump.hprof
Unbelievable tool to see all of the threads and stack of these threads. You can also dump you threads when you run JVM in foreground by pressing Ctrl+\ in Linux terminal however usually it is not the case.
jstack 9762
"Attach Listener" daemon prio=10 tid=0x00007f3be4003000 nid=0x35b6 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Inactive RequestProcessor thread [Was:org.netbeans.spi.project.ui.support.NodeFactorySupport/org.netbeans.spi.project.ui.support.NodeFactorySupport$DelegateChildren$2]" daemon prio=10 tid=0x00007f3bfc60f000 nid=0x35a9 in Object.wait() [0x00007f3bc3ffe000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1942)
- locked <0x00000007e86a2940> (a java.lang.Object)
...
Newer versions of jstack can also try to detect deadlocks in your code.
jmapPrints information on the shared libraries loaded by JVM. Can be useful if you use JNI.
jmap 9762
0x00000030e9200000 87K /lib64/libgcc_s-4.6.1-20110908.so.1
0x000000377f000000 42K /lib64/libcrypt-2.14.so
...
But it's also able to create a detailed JVM dump which can be viewed by jhat tool later. You can download this dump to your developer host.
jmap -dump:file=test.dmp 9762
Heap dump file created
jhat
It's not just a tool, it's a small server which parses the dump created by jmap and provides HTML interface to view dump data.
jhat test.dmp

It will show you lots of details on your objects and relations between them in various dimensions.
As you see there's a bunch of interesting tools which will allow you to understand what's happening with the remote JVM. Of course they are more complex in comparison to VisualVM or JProfiler but there are definitely some circumstances when these tools can be useful. And you don't need to install anything additional since all these tools bundled with the JDK.
0 comments:
Post a Comment