JVM Command-java Server troubleshooting

Source: Internet
Author: User
Tags session id uppercase letter cpu usage

First, Top (Linux command)

Execute the top command: (see the details of process 15477, used below)

 

System Information (first five elements):

    • Line 1th: Top task Queue information (System run state and average load), same as uptime command results.
      • 1th: The current time of the system, for example: 16:07:37
      • The 2nd paragraph: the system running time, not restart the time, the longer the system more stable.
        • Format: Up xx days, hh:mm
        • For example: 241 days, 20:11, indicates continuous operation for 241 day, 20 hours, 11 minutes
      • 3rd: The number of currently logged on users, for example: 1 user, indicating that only 1 users are currently logged in
      • 4th: System load, that is, the average length of the task queue, 3 values statistics of the last 1, 5, 15 minutes of the system average load
        • System average load: Single core CPU, 0.00 means no load, 1.00 means just full load, more than 1 side means overload, ideal value is 0.7;
        • Multi-core CPU Load: CPU Cores * Ideal value 0.7 = Ideal load, for example: 4 cores CPU load not more than 2.8 what means no high load.
    • Line 2nd: Tasks Process Related information
      • 1th: Total number of processes, for example: tasks:231 total, which indicates that 231 processes are running
      • 2nd: Number of running processes, for example: 1 running,
      • The 3rd paragraph: the number of sleep processes, for example: sleeping,
      • 4th: The number of stopped processes, for example: 0 stopped,
      • 5th: Number of zombie processes, for example: 0 Zombie
    • Line 3rd: Cpus CPU-related information, if it is a multi-core CPU, according to the number 1 can display the core CPU information, the 1 will be converted to the CPU core number of lines, the number 1 can be switched back and forth.
      • 1th: us CPU percentage occupied by user space , for example: CPU (s): 12.7%us,
      • 2nd: sy CPU percentage in kernel space, for example: 8.4%sy,
      • 3rd: ni The percentage of CPU that has changed priority in user process space, for example: 0.0%ni,
      • 4th: id Percentage of idle CPU, for example: 77.1%id,
      • 5th: wa The percentage of CPU time waiting for input and output, for example: 0.0%wa,
      • 6th: hi The total amount of time the CPU spends on hardware outages, for example: 0.0%hi,
      • 7th: si The total amount of time spent by the CPU service soft interrupt, for example: 1.8%si,
      • 8th: st steal the time that the virtual machine was hypervisor stolen by the CPU (if the VM is currently in a hypervisor, hypervisor is actually consuming a portion of the CPU processing time)
    • Line 4th:Mem Memory related information (mem:12196436k total, 12056552k used, 139884k free, 64564k buffers)
      • 1th: The total amount of physical memory, for example: mem:12196436k totals,
      • 2nd: The total amount of physical memory used, for example: 12056552k used,
      • 3rd: Total idle memory, for example: mem:139884k free,
      • 4th: Amount of memory used as the kernel cache, for example: 64564k buffers
    • Line 5th: Swap partition related information (swap:2097144k total, 151016k used, 1946128k free, 3120236k cached)
      • 1th: Total swap area, e.g. swap:2097144k
      • 2nd: The total amount of swap used, for example: 151016k used,
      • 3rd: The total amount of idle swap, for example: 1946128k free,
      • 4th: Total buffer swap area, 3120236k cached

Process information:

Press f in the top command to view the displayed column information, press the corresponding letter to open/close the column, the uppercase letter to open, and the lowercase letter to close. The default column is the one with the * number.

    • A: PID = (Process ID) session ID;
    • E: USER = user name of the (user name) process owner;
    • H: PR = (priority) Precedence
    • I: NI = nice value. Negative values indicate high priority, positive values indicate low priority
    • O: VIRT = The total amount of virtual memory used by the process (virtual Image (KB)), Unit Kb. Virt=swap+res
    • Q: RES = (resident size (KB)) the size of the physical memory, in kilobytes, that the process uses, not swapped out . Res=code+data
    • T: SHR = (shared Mem size (KB)) share memory size, in kilobytes
    • W: S = (Process status) session state. d= non-disruptive sleep status, r= run, s= sleep, t= track/Stop, z= zombie process
    • K: %CPU = (CPU usage) CPU time consumption percentage last updated to current
    • N: %MEM percent of physical memory used by the session = (Memory usage (RES)) process
    • M:TIME+ = (CPU time, hundredths) the total CPU times used by the process, units 1/100 seconds
      B:PPID= (Parent process Pid)
      C:RUSER= (Real user name)
      D:UID= User ID of the process owner
      F:GROUP= Group name of the process owner (group name)
      G:TTY= (controlling Tty) The terminal name of the boot process. Processes that are not started from the terminal are displayed as?
      J:P= (last used CPU (SMP)) finally used CPU, only meaningful in multi-CPU environment
      P:SWAP= (swapped size (KB)) process used in virtual memory, the size of the swapped out, in kilobytes
      LTIME= Total CPU time used by the process, in seconds
      R:CODE= (code size (KB)) The amount of physical memory the executable code occupies, in kilobytes
      SDATA= (data+stack size (KB)) The amount of physical memory that is used outside the executable code (data segment + stack), in kilobytes
      UnFLT= (page Fault count) page error count
      V:nDRT= (Dirty pages count) Last written to now, number of pages modified
      Y:WCHAN= (sleeping in Function) if the process is sleeping, the system function name in sleep is displayed
      Z:Flags= (Task flags <sched.h>) task flag, reference sched.h
    • X: COMMAND = (Command name/line) name/command line

Refer to the Linux Performance analysis tool top command

Perform top-hp PID, such as TOP-HP 15477

View threads in a process Note: The PID is the thread ID at this time

If thread 15571 has an exception to look for, use the Jstack print stack to view Thread 15571 status (15571 16 binary =3CD3)

Second, Jstack

Refer to the Java Command--jstack tool

Java Command Learning Series (ii)--jstack

Need to be used in the JDK installation directory (the Java process can be viewed through PS x to get the JDK installation directory)

./jstack PID (Process id)./jstack 15477

Thread 15571 (16 =3cd3) state in red box

Analyze Jstack logs:

Monitors monitor:

Monitor is the primary means of using Java to achieve mutual exclusion and collaboration between threads, which can be seen as an object or class lock.

Every object has, and only one monitor.

The following diagram depicts the relationship between a thread and monitor, and the state transitions of a thread:

Entry Zone (ENTRT Set): Indicates that the thread acquires the lock of the object through synchronized requirements. If the object is not locked, enter the owner, otherwise wait in the entry area. Once the object lock is freed by another thread, participate in the competition immediately.

Owner (the owner): indicates that a thread successfully competes to the object lock.

Wait Set: Indicates that the thread is releasing the lock of the object through the object's Object.wait () method, and waits in the wait area to be awakened.

As can be seen, a monitor at some point, can only be owned by one thread, and the “Active Thread” other threads are “Waiting Thread” , respectively, in two queues “ Entry Set” and “Wait Set” inside wait.

The “Entry Set” thread that waits in the action is“Waiting for monitor entry”。

The “Wait Set” thread that waits in the action is “in Object.wait()” . When a thread requests to enter a critical section, it enters the "Entry Set" queue.

(We call the code snippet protected by synchronized as a critical section.) When a thread requests to enter a critical section, it enters the "Entry Set" queue)

Thread State:

NEW: Not started. does not appear in dump.

RUNNABLE: In-run state within a virtual machine. The owner area

BLOCKED: Blocked and waiting for monitor lock. lock in entry set area .

wating: Waits indefinitely for another thread to perform a specific operation. Wait for a condition or monitor to occur in the wait set area , usually in a wait () statement.

timed_wating: A time-bound wait for a specific operation on another thread. The difference between the wait set area and the waiting is that the wait () statement adds a time limit of wait (timeout).

TERMINATED: exited.

Call adornments

Represents an extra important operation for a thread when it is called by a method. Modifies the method call above.

locked < address > Destination: Use synchronized to apply the object lock successfully, the owner of the Monitor. The owner area.

waiting to lock < address > target: Use synchronized to request that the object lock is unsuccessful, such as in the entry set area. Thread state is blocked

waiting on < address > target: After the object lock is successfully used with synchronized, the lock is released and locks are locked in the wait set area. Thread state is waiting or timed_wating

parking to wait for < address > destination: Call Park (), waiting for permission in the wait set area.

(Park is a basic thread blocking primitive that does not block through the monitor on the object.)

Park: Enter waiting state, compare wait do not need to acquire lock to let thread waiting, wake by Unpark)

Thread action

The reason for the thread state to occur.

runnable: The owner zone, State runnable

In object.wait (): Call Wait (), wait set area, state waiting or timed_waiting, decorate waiting on

Waiting for monitor entry: Equal lock, entry set zone, state blocked, decorate waiting to lock

Waiting on condition: Due to a condition park,wait the set zone, the status is parking to Wait for

sleeping: Dormant thread, called Thread.Sleep ()

Third, JPS

Similar to Linux command PS

Reference Java Command Learning Series (i)--jps

./jps

./jps-q

./jps-m

./jps-l

./jps-v

Iv. Jmap

Reference Java Command Learning Series (iii)--JMAP

The Java Command--jmap command uses the

Jmap-heap PID: Heap Usage

Jmap-histo PID: Object condition

(jmap-histo:live This command executes, the JVM triggers the GC first, and then the statistical information

Focus on the class on the item: [C is an array of strings, string is used; [B is a byte array, which is used by the network layer.] These two are bigger and generally okay.

[C is a char[]
[S is a short[]
[I is a int[]
[B is a byte[]
[[I is a int[][]

)

JVM Command-java Server troubleshooting

Related Article

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.