Java Virtual Machine study notes (c) - debugging and tuning

Disclaimer: This article is a blogger original, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/weixin_36904568/article/details/90273149

A: Debugging

1. command-line tool

(1) jps: VM process status tool

Lists the virtual machines running processes, displays a unique ID to run the main class and processes in the local virtual machine (LVMID)

Format: jps - command process ID

  • -q: Output LVMID
  • -l: class name, or output of the main path jar
  • -v: JVM parameters when the output process starts
  • -m: parameters passed to the main function of the output process starts

(2) jstat: Virtual Machine Statistics Monitoring Tool

Command to monitor virtual machines running various status information line tools, including local or remote virtual machine process of class loading, memory, garbage collection, JIT compiler and other operating data. Positioning is the preferred tool runtime virtual machine performance

Format: jstat - interval command process ID queries queries

  • -class: spatial and time of loading and unloading the number of monitor class spent
  • -gc: monitoring the status of the heap
    • -gccapacity: Heap use of space
    • -gcutil: used / total space
    • -gcnew: Cenozoic
    • -gcold: years old
    • -gcpermcapacity: Permanent Generation
  • -compiler: Output JIT compiler compiled method, time-consuming
  • -printcompilation: JIT compiler output compiled method

(3) jinfo: Java configuration tool

Real-time view and adjust the parameters of the virtual machine

Format jinfo - command process id

  • -flag: view the configuration parameters of the virtual machine
  • Modify the virtual machine configuration parameters: -flag name = value
  • -sysprops: print the contents of a virtual machine getProperties

(4) jmap: Java memory imaging tools

Health Information heap dump snapshot dump file, query finalize queue, Java heap and permanent generation

Format jmap - command vmid

  • -dump: Health heap dump snapshot
  • -histo: statistics object on the heap
  • -heap: Details of the heap
  • -finalizeinfo: Query finalize queue
  • -permstat: permanent generation information

(5) jhat: a snapshot of the virtual machine heap dump analysis tool

And jmap with the use of Java through the built-in HTTP / HTML server-generated analysis of the dump file

(5) jstack: Java stack trace tool

Generating a virtual machine snapshot of the current time threads (each a set of methods executing thread stack), the main thread is used to locate the cause of the emergence of a long pause

Format jstack - command vmid

  • -F: Force Output
  • -l: Additional information display lock
  • -m: display native method stack

2. Visualization Tools

(1) JConsole: Java Monitoring and Management Console

Visualization JMX-based monitoring and management console by JConsole.exe under jdk / bin Run

  • Management: Managing for the JMX MBean
  • Monitoring: You can monitor virtual machines running processes
    • Memory: Visualization jstat command, for monitoring the change of the virtual machine managed by the collector memory (heap and permanent generation)
    • Thread: Visualization jstack command for monitoring change thread
    • Class: Visualization jstat command, monitoring for loading and unloading of classes
    • VM profiles

(2) VisualVM: in-one troubleshooting tool

Jvisualvm.exe run by the jdk / bin

  • Display the configuration of the virtual machine process and process (jps, jinfo)
  • Monitoring the application CPU, GC, heap, the method area, a thread (jstack, jstat)
  • dump, analyze heap dump snapshot (jmap, jhat)
  • Offline snapshot program
  • Program Performance Analysis

II: Tuning

  • Disk IO
  • database
  • Resource pool
  • RAM
  • GC
    • Minro GC: Area View Eden, Survivor zone size (capacity provided by -Xmn)
    • Full GC: Check years old and permanent generations of memory area (with -Xmx, -Xms fixed capacity)
    • GC collector

(1) high-performance hardware deployment

  • Larger memory used by the 64-bit JDK
    • Memory recovery will lead to long pause
    • Lower performance
    • Unable to generate a heap dump snapshot
  • Use a number of 32-bit virtual machine, create a logical cluster
    • A plurality of nodes compete for resources
    • Unable to efficient use of resources pool
    • By 32 (4GB) of memory limits

(2) Memory Overflow

Use tool to monitor memory section

  • Curve Up: Memory Expansion
  • Downward curve: memory recovery

Synchronization between clusters

Large network synchronization overhead, network conditions can not meet the transmission case, lead to information sent by the accumulation in memory, a memory leak

Heap external memory

  • Direct memory: by -XX: MaxDirectMemorySize set the size
  • Thread stack: by -XX: Xss set the size
  • Socket buffers
  • JNI code
  • The virtual machine itself

Guess you like

Origin blog.csdn.net/weixin_36904568/article/details/90273149