1. Command line tools
- jps is
equivalent to the ps (tasklist in windows process) of the Linux operating system, which is used to display the java process number.
Usage:
jps [-option]
Parameters:
-l: display the full class name
-q: omit the class name and only display the port number
-v: display the parameters of the virtual machine
-m: display the parameters of the running main class - jstat
displays class loading information,
memory distribution, garbage collection, jit editing information, class loading information, etc.
jsta - gcutil 端口号 次数
- Jinfo can also
jinfo -flag 端口号
view or modify a parameter of the virtual machine
java -XX:+PrintFlagsFinal - jmap
generates snapshot information
jmap -dump:format=b,file=d:\a.bin 8008
- Jhat
analyzes the classes in the snapshot.
jhat d:\a.bin
All class information will appear when accessing the local port 7000. - jstack
jstack [option] vmid
-l Display additional lock information
-F Mandatory
-m C/C++ stack can be displayed if local method is called
#用来打印thread信息
Map<Thread, StackTraceElement[]>map = Thread.getAllStackTraces();
for(Map.Entry<Thread, StackTraceElement[] >en : map.entrySet()){
Thread t = en.getKey();
StackTraceElement[] v = en.getValue();
System.out.println("Thread:" + t.getName());
for(StackTraceElement s : v){
System.out.println("\t" + s.toString());
}