Performance problem Locating Method

Source: Internet
Author: User

 

1Use commandsJPS //ViewBootstrapOrPS-Ef | grep Java | grep $ userOr.

Command Format: JPs // PID of process Bootstrap

Or PS-Ef | grep Java | grep $ user // portal application PID

 

 

 

2Use commandsJstack //Print thread Stack

Command Format: jstack pid> jstack.txt

 

Checkpoint:

① Whether a deadlock exists

E.g. There are no deadlocks in the following four cases.

 

② Whether there are a large numberBlockedStatus of the same thread.

 

3Use commandsJmap-heap //Print memory usage

Command Format: jmap-heap pid> heap.txt

 

 

Checkpoint:

① Check the new generation in memoryYoung GenerationOld GenerationOld Generation, Permanent generationPerm generation. Pay attention to the memory usage of the old generation.90%The above may cause memory leakage. This can be combinedGCCheck logsFull GCWhether the problem has occurred.

[Case Study1]

Concurrent operations100User (s)WAPThe memory is configured2G, About run12About hours,TPSThe value begins to show a downward trend.CPUUsage has been in80%Left and right. Due to the large number of printed logs12The hour log has been overwritten, so it cannot be located from the log.

 

1First, analyze the memory usage

 

For example, the old generation is almost full.

2And then checkGCLogs,Tomcat/bin/gc.txtFor example,Full GCThe appearance frequency is also high, and onceFull GCUp315 sThis phenomenon is abnormal. Here we need to know the sequence of memory usage: first use the new generation, and in the new generation, the threads that are difficult to recycle garbage will be transferred to the old generation, and then useFull GCProcess threads in the old generation. NowFull GCBut the space of the old generation cannot be cleared, and memory leakage may occur.

 

3Analyze which objects occupy a large amount of memory

 

For example, the two processes marked by red pen occupy a large amount of memory, lock the suspicious target, and close the job.

 

4Use commandsJmap-heap: format = B //Print memory image, also called memory Stack

Command Format: jmap-heap: format = B PID

After this command is used, heap. Bin is generated in the local directory. Check whether heap. Bin exists before running it to avoid overwriting.

 

Note: because the size of the screenshot memory image is similar to that configured in Catalina. Sh, You need to reserve enough space. If the memory is 2 GB, it will take about 10 minutes.

Checkpoint:

① I still don't know how to check

 

5Use commandsJmap-histo //Print the number of objects of Different Types

Command Format: jmap-histo pid> histo.txt

Checkpoint:

① Check which processes occupy a large amount of memory

 

 

 

6.Tomcat/binThe followingCatalina. ShAdd to file-Xloggc: GC. LogPrintableGCLogs

PS-fu $ user | grep SAR | grep-V grep | awk '{print $2}' | xargs kill-9>/dev/null 2> & 1

 

Java_opts = "$ java_opts-server-xms2048m-xmx2048m-XX: permsize = 512 M-XX: maxnewsize = 512 M-XX: maxpermsize = 512 M-djava. AWT. headless = true-xloggc: GC. log"

# Java_opts = "$ java_opts-xdebug-xnoagent-xrunjdwp: Transport = dt_socket, Server = Y, suspend = N, address = 14444"

Java_opts = "$ java_opts -djava.net. preferipv4stack = true"

 

# Jconsole ARGs

# Java_opts = "$ java_opts-DCOM. sun. management. jmxremote. port = 29819-DCOM. sun. management. jmxremote. authenticate = false-DCOM. sun. management. jmxremote. SSL = false"

# Get heap dumps

# Java_opts = "$ java_opts-XX: + heapdumponctrlbreak"

 

# JVM debuging Params

# Java_opts = "$ java_opts-verbose: GC-xloggc: GC. Log-XX: + printgcdetails"

# Java_opts = "$ java_opts-XX: + showmessageboxonerror-verbose: GC-verbose: JNI-xprof-xloggc: GC. Log-XX: + printgcdetails"

 

 

 

Performance problem Locating Method

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.