JVM common parameters and monitoring tools use JDK location problem

JVM arguments

JVM parameter types

  • Standard parameters
  • X-parameters
  • XX parameter
    • Boolean type
      • Formula: -XX: + or - a property value (+ indicates ON - disabled)
      • For example: -XX: + PrintGCDetails (GC open log), - XX: -PrintGCDetails (GC log off)
    • KV set value type
      • Formula: -XX: key = attribute value attribute value
      • For example: -XX: MetaspaceSize = 128m (element space is provided), - XX: MaxTenuringThreadhold = 15 (number of generations set points)
    • Description: -Xms, -Xmx, -Xss are abbreviations

Common parameters

  • View JVM defaults

    • -XX:+PrintFlagsInitial
      • Value for each parameter initialization JVM print
    • -XX:+PrintFlagsFinal
      • Print final (current) value for each parameter of the JVM
    • -XX:+PrintCommandLineFlags
      • JVM parameters print run command line settings
  • Set each space

    • -Xms
      • Heap initialization value
    • -xmx
      • Heap maximum (default quarter-memory)
    • -Xss
      • Virtual stack memory (default 1024k)
    • -XX:MetaspaceSize
      • Initialization element space size (default 20m)
    • -XX:MaxMetaSpaceSize
      • Yuan maximum space (the default is no limit)
    • -XX:MaxDirectMemorySize
      • Direct operating memory size that is not operating virtual machine's memory (RAM quarter of default)
  • Garbage collection related

    • View Recycling Information
      • -XX:+PrintGCDetails
        • Open GC logs
      • +XX:+PrintGCTimeStamps
        • Print each GC timestamp
    • Select the collector
      • +XX:UseSerialGC
        • Serial (new generation) + SerialOld (years old)
      • +XX:UseParNewGC
        • ParNew (new generation) + SerialOld (years old)
      • +XX:UseParallalGC
        • Parallal (new generation) + ParallalOld (years old)
      • +XX:UseParallalOldGC
        • Parallal (new generation) + ParallalOld (years old)
      • +XX:UseConcMarkSweepGC
        • Parallal (new generation) + CMS (years old) + SerialOld (emergency exits)
      • +XX:UseG1GC
        • G1 (new and old)
    • Garbage collection parameters
      • -XX:MaxTenuringThreadhold
        • The number of years required to enter the old, default 15
    • Garbage collection-related parameters (non-G1)
      • -XX:MaxNewSize
        • Cenozoic default maximum memory 16M
      • -XX:NewRatio
        • The old and the young generation's size ratio, the value is an integer, the default is 2
      • -XX:SurvivorRatio
        • Eden area and the ratio of the size of the region Survivor, an integer value, the default is 8
    • Garbage collection-related parameters (G1)
      • -XX:G1HeapRegionSize
        • The size of the area G1 provided. Value is a power of 2, the range of 1MB to 32MB. Goal is to divide the region of about 2048 based on the smallest Java heap size.
      • -XX:MaxGCPauseMillis
        • The maximum GC pause time, this is a soft target, JVM will try (but not guarantee) stop less than this time.
      • -XX:InitiatingHeapOccupancyPercent
        • The number of occupied heap when he triggered GC, the default is 45
      • -XX:ConcGCThreads
        • GC number of concurrent threads used.
      • -XX: G1ReservePercent
        • Set aside as a percentage of free memory, in order to reduce the risk of the target space overflow, the default value is 10%

identify the problem

View Linux performance

  • Machine: top
    • uptime, system performance commands Lite
  • CPU:vmstat
    • See CPU (not contained in)
    • View Extra
      • View all cpu core information mpstat -P ALL 2
      • Each process uses an amount of cpu decomposition process number information pidstat -p -u sampling interval in seconds
  • Memory: free
    • The number of available application memory free, free -g, free -m
    • generally
      • Applications available memory / physical memory of> 70% of memory sufficient.
      • Memory available to the application / system physical memory <20% out of memory, the memory needs to be increased.
      • 20% <memory available to the application / system physical memory <70% basic enough House
    • View Extra
      • pidstat -p process ID -r sampling interval in seconds
  • Hard disk: df
    • View the number of disk space df -h
  • Disk IO: iostat
    • Disk I / O performance evaluation iostat -xdk 2 3
    • View Extra
      • pidstat -p process ID -d sample interval in seconds
  • Network IO: ifstat
    • No local default download ifstat

Positioning steps
combined with Linux and JDK command an analysis

  • First find the highest proportion of the CPU with the top command

  • ps -ef or jps further positioning, that is a background program which is

  • Threads, or code to target specific

    • ps -mp process id -o THREAD, tid, time
    • Parameter Description
      • -m Show all threads
      • -p pid process uses the cpu time
      • This parameter is -o user-defined format
  • The conversion requires a thread ID in hexadecimal format (English lowercase)

  • jstack process ID | grep (16 hex thread ID lowercase) -A60
    Here Insert Picture Description

  • JDK that comes with JVM monitoring and performance analysis tools

    • jps

      • JVM process status tool, mainly used to run the JVM output of the process status information
      • jps [options] [hostid]
        • -q: does not output the class name, Jar name and incoming main method parameters
        • -m: Output parameter passed to the main method
        • -l: Jar of output main class or the fully qualified name
        • -v: Output parameter passed in the JVM
        • If you do not specify it defaults to the current host hostid or a server.
    • jhsdb

      • jdk11 in recommendations: jstack, jmap (must), jinfo, before jsnap command, use the command jhsdb
        Here Insert Picture Description
    • jinfo

      • jvm parameters detailed information jinfo java command to view the running process, such as maximum heap memory, what garbage collector uses, etc.
      • jinfo -flags pidView all jvm java process specified operating parameters
        Here Insert Picture Description
      • jinfo -flag param pidView a parameter
        Here Insert Picture Description
    • jstack

      • To view the thread stack information within a Java process, thread stack, real-time monitoring information system is running, without having to halt the investigation, commonly used in online troubleshooting system, usually a time lag using the command to print out the current system jstack real-time snapshot, and then compare the thread execution state in the lock system to determine whether there is a deadlock, excessive competition and other issues.
      • jstack [option] pid
        jstack [option] executable core
        jstack [option] [server- id@ ]remote hos tname-or- ip
        • -l: long listings, will print out additional lock information, you can use jstack -l pid locks held to observe the situation when a deadlock occurs
        • -m mixed mode, not only will output Java stack information will be printed in C / C ++ stack information (such as Native Method)
      • jstack -l pidView a JVM process all threads
        Here Insert Picture Description
      • jstack -l pid | grep tidView a JVM process specified thread
        Here Insert Picture Description
    • jhsdb jmap

      • See for jmap heap memory (the memory of generation of each case, the target occupancy JVM) usage, the JVM can also export the entire memory information, generally used in combination jhat. If you do not use this command, you can use -XX: + HeapDumpOnOutOfMemoryError parameters to allow virtual machines OOM occurs when the automatically generated dump file.

      • jmap outdated and must be used in jdk11 jsdb jmap

      • jmap -heap [pid]View the entire JVM memory usage (also contains JDK version, GC policy-related, etc.).
        Here Insert Picture Description

      • jmap -finalizerinfo pidPrint object information waiting for recycling
        Here Insert Picture Description

      • jmap -histo [pid]View details of the object survived the JVM heap usage, commonly used in the analysis OutOfMemory
        Here Insert Picture Description

      • jmap -dump pidHeap to file

        Here Insert Picture Description
        Use VisualVM analysis .hprof file
        Here Insert Picture Description

    • jstat

      • JVM statistics monitoring tools, real-time monitoring system used to heap usage and GC information, compile information, class loading information used to determine whether the system JVM parameters to set reasonable, as a system parameter tuning information statistical tools.
      • jstat [ general0ption| outputOptions vmid [ interval[s |ms] [ count]] ]
        • general0ption jstat according to statistics of different dimensions, you can use the options in the following table of statistics different dimensions, different options supported by the operating system may be different, you can -options option to view the different operating systems supported options.

          -Class	    		用于查看类加载情况的统计
          -compiler			用于查看HotSpot中即时编译器编译情况的统计
          -gc					用于查看JVM中堆的垃圾收集情况的统计
          -gccapacity			用于查看新生代、老生代及持久代的存储容量情况
          -gccause			用于查看垃圾收集的统计情况(这个和- gcutil选项一样),如果有发生垃圾收集,它还会显示最后一次及当前正在发生垃圾收集的原因。
          -gcnew 				用于查看新生代垃圾收集的情况
          -gcnewcapacity		用于查看新生代的存储容量情况
          -gcold 				用于查看老生代及持久代发生GC的情况
          -gcoldcapacity		用于查看老生代的容量
          -gcpermcapacity		用于查看持久代的容量
          -gcutil				用于查看新生代、老生代及持代垃圾收集的情况
          -printcompilation	HotSpot编译方法的统计
          
        • outputOptions

          • -h: used to specify the output column every few lines on the head, if not specified, the default is the emergence of the first column only the first line.
          • -J: for a given pass javaOption java application loader, e.g., "- J-Xms48m" will be set to start the memory 48M.
          • -t: The first column is used to output the contents of the presentation time stamp, the time stamp on behalf of the JVM started till now
        • vmid virtual machine ID, on LinuxUnix system in general is the process ID.

        • the sampling interval is the time interval in milliseconds MS .

        • count is the number of samples.

      • example
        Here Insert Picture Description
        Here Insert Picture Description
    • Parameters (from: https: //blog.csdn.net/fenglibing/article/details/6411951)
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description
      Here Insert Picture Description

Published 109 original articles · won praise 47 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_43934607/article/details/104393563
Recommended