JDK analysis tools: JPS and Jstack

Source: Internet
Author: User

JPS

Used to view: Based on the specific state of all processes within the Hotspot JVM, including the process ID, path of process initiation, and so on.

Similar to PS on UNIX, used to display locally-privileged Java processes, you can view a few Java programs running locally and display their process numbers.

When using JPS, you do not need to pass the process number as a parameter.

JPS can also display the Java process on a remote system, which requires the Jstat service on the remote service, as well as RMI notes and services, but is often viewed on the local Java process. Command format

JPS [Options] [HostID] Common parameter description

The-m output is passed to the main method parameter, and if it is an inline JVM, the output is null.

-L OUTPUT The full package name of the application main class, or the full path to the application jar file.

-V output passed to the JVM parameters. Using the example

[Email protected]:~$ JPS8710Jps5661Bootstrap2491 2967[email protected]-pc:~$ JPS-ml5661org.apache.catalina.startup.Bootstrap Start2491 8724 Sun.tools.jps.Jps-ml2967[email protected]-pc:~$ JPS-MLV5661 Org.apache.catalina.startup.Bootstrap start-djava.util.logging.config.file=/home/blue/apache-tomcat-7.0.39/ conf/logging.properties-djava.util.logging.manager=org.apache.juli.classloaderlogmanager-djava.endorsed.dirs=/ home/blue/apache-tomcat-7.0.39/endorsed-dcatalina.base=/home/blue/apache-tomcat-7.0.39-dcatalina.home=/home/ blue/apache-tomcat-7.0.39-djava.io.tmpdir=/home/blue/apache-tomcat-7.0.39/Temp2491-dosgi.requiredjavaversion=1.5-xx:maxpermsize=256m-xms40m-xmx384m8738 sun.tools.jps.jps-mlv-dapplication.home=/usr/local/jdk1.6.0_35-xms8m2967-dosgi.requiredjavaversion=1.5-xx:maxpermsize=256m-xms40m-xmx512m

The preceding number is the process ID of the JVM, followed by the class startup information for the JVM. Jstack

If a Java program crashes generating a core file, the Jstack tool can be used to obtain information about the core file's Java stack and the native stack, making it easy to know how the Java program crashes and where the problem occurs in the program. In addition, the Jstack tool can be attached to a running Java program to see the Java stack and the native stack of the Java program that was running, and jstack is useful if the Java program that is running now renders hung state. Command format

$jstack [option] pid

$jstack [option] executable core

$jstack [option] [[Email protected]]remote-hostname-or-ip Common parameter description

OPTIONS

-F Jstack [-l] PID cannot respond when forcing the print stack

L long list. Prints additional information about the lock, such as the ownable synchronizers list belonging to Java.util.concurrent.

-m mixed-mode output (including Java and local C + + fragment) stacks.

The process number of the Pid:java application can be obtained by JPS;

Executable: Java executable program that produces core dump;

Core: Print out the core file;

REMOTE-HOSTNAME-OR-IP: Name or IP of the remote debug server;

Server-id: Unique ID, if there are multiple remote debug services on a host, using the example

[Email protected]:~$ JPS-ml5661org.apache.catalina.startup.Bootstrap [email protected]-pc:~$ Jstack 56612013-04-16 21:09:27Full thread dump Java HotSpot (TM) Server VM (20.10-b01 Mixed mode):"Attach Listener" daemon prio=10 tid=0x70e95400 nid=0x2265 waiting on condition [0x00000000] Java.lang.Thread.State:RUNNABLE"http-bio-8080-exec-20" daemon prio=10 tid=0x08a35800 nid=0x1d42 waiting on condition [0x70997000] Java.lang.Thread.State:WAITING (parking) at Sun.misc.Unsafe.park (Native Method)-Parking to wait for<0x766a27b8>(a java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject) at Java.util.concurrent.locks.LockSupport.park (Locksupport.java:156) at Java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject.await ( Abstractqueuedsynchronizer.java:1987) at Java.util.concurrent.LinkedBlockingQueue.take (Linkedblockingqueue.java:399) at Org.apache.tomcat.util.threads.TaskQueue.take (Taskqueue.java:104) at Org.apache.tomcat.util.threads.TaskQueue.take (Taskqueue.java:32) at Java.util.concurrent.ThreadPoolExecutor.getTask (Threadpoolexecutor.java:947) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:907) at Java.lang.Thread.run (Thread.java:662) .....

In general, the thread information output through Jstack mainly includes: JVM itself thread, user thread, etc. Where the JVM thread will be present when the JVM is started. The user thread is generated when the user accesses it.

JDK analysis tools: JPS and Jstack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.