linux view java stack

1. View the JVM parameters of the JAVA process

jinfo -flags pid (process ID)
-XX: CICompilerCount 2 = the maximum number of parallel compilation
-XX: InitialHeapSize = 16777216 JVM initial heap size
-XX: MaxHeapSize = 257949696 JVM maximum heap size
-XX: MaxNewSize = 85,983,232
- XX:MinHeapDeltaBytes=196608
-XX:NewSize=5570560
-XX:OldSize=11206656
 

2, JVM view the startup parameters of the current Java process

jmap -heap [process number]

NewRatio: Specify the heap memory ratio of the old generation/new generation, the default is 2:1. In the hotspot virtual machine, heap memory = new generation + old generation. When -XX:MaxNewSize is set, the value of -XX:NewRatio will be ignored, the memory of the old generation = heap memory-the memory of the new generation. Maximum memory in the old generation = heap memory-maximum memory in the new generation.

SurvivorRatio: The ratio of the size of one Eden area to one Survivor area in the Cenozoic. In the hotspot virtual machine, the new generation = 1 Eden + 2 Survivor. If the new generation memory is 10M and SurvivorRatio=8, then the Eden area occupies 8M, and the two Survivor areas each occupies 1M.

The Eden area is one block, and the Survivor area is two blocks.

The ratio of Eden area to Survivor area is 8:1:1

The structure of JVM memory is
Heap: store objects,
stack: store stack frames at runtime,
program counter,
method area: store classes and constants

After Jdk 1.8, the method area seems to be cancelled, and the permanent generation is directly placed in the local memory.

3. Jstat can be used to monitor the size and memory usage of various heaps and non-heaps in VM memory.

jstat -gcutil pid

Through the jstat -gcutil pid command, we can perform statistics on gc information.

jstat -gc pid

This command seems to display more information than the previous command. jstat -gc pid can display gc information, check the number of gc, and time. The last five items are the number of young gc, the time of young gc, the number of full gc, the time of full gc, and the total time of gc.

jstat -gccapacity pid

The jstat -gccapacity pid command can display: the usage and occupancy size of the three generations (young, old, perm) objects in the VM memory. For example: PGCMN shows the memory usage of the minimum perm, PGCMX shows the maximum memory usage of the perm, PGC is the memory usage of the newly generated perm, and PC is the memory usage of the previous perm. Others can be deduced by this analogy, OC is the pure occupancy in old.

jstat -gcnew pid

The jstat -gcnew pid command can display information about young generation objects.

jstat -gcnewcapacity pid

The jstat -gcnewcapacity pid command can display the information of the young generation objects and their occupancy.

jstat -gcold pid

The jstat -gcold pid command can display information about old generation objects.

jstat -gcoldcapacity pid

The jstat -gcoldcapacity pid command can display the information of the old generation object and its occupancy.

jstat -class pid

The jstat -class pid command can display information such as the number of loaded classes and the space occupied.

jstat -compiler pid

The jstat -compiler pid command can display information such as the number of real-time compilations of the VM.

jstat -printcompilation pid

The jstat -printcompilation pid command can display information about the current VM execution.

Parameter explanation

  • S0C: The capacity of the first survivor in the young generation (kb)
  • S1C: The capacity of the second survivor in the young generation (kb)
  • S0U: The first survivor (survivor area) in the young generation currently used space (kb)
  • S1U: The second survivor (survivor area) in the young generation currently used space (kb)
  • EC: The capacity of Eden in the young generation (kb)
  • EU: Eden (Eden) in the young generation currently used space (kb)
  • OC: Old generation capacity (kb)
  • OU: Old generation currently used space (kb)
  • PC: Perm (persistent generation) capacity (kb)
  • PU: Perm (persistent generation) currently used space (kb)
  • YGC: the number of gc in the young generation from the start of the application to the sampling
  • YGCT: The time spent by gc in the young generation from the start of the application to the time of sampling (s)
  • FGC: The number of old generation (full gc) gc from the start of the application to the sampling
  • FGCT: The time (s) from the start of the application to the old generation (full gc) gc at the time of sampling
  • GCT: The total time used by gc from the start of the application to the time of sampling (s)
  • NGCMN: Initialized (minimum) size (kb) in the young generation (young)
  • NGCMX: Maximum capacity (kb) of the young generation (young)
  • NGC: Current capacity (kb) in the young generation (young)
  • OGCMN: Initialized (minimum) size (kb) in the old generation
  • OGCMX: the maximum capacity of the old generation (kb)
  • OGC: The current newly generated capacity of the old generation (kb)
  • PGCMN: Initialized (minimum) size (kb) in perm generation
  • PGCMX: Maximum capacity of perm generation (kb)
  • PGC: current newly generated capacity of perm generation (kb)
  • S0: The first survivor (survivor area) in the young generation has been used as a percentage of the current capacity
  • S1: The second survivor (survivor area) in the young generation has been used as a percentage of the current capacity
  • E: Eden (Eden) in the young generation has used percentage of current capacity
  • O: The percentage of the current capacity used by the old generation
  • P: Perm generation has used the percentage of current capacity
  • S0CMX: The maximum capacity of the first survivor in the young generation (kb)
  • S1CMX: The maximum capacity of the second survivor (survivor area) in the young generation (kb)
  • ECMX: The maximum capacity of Eden in the young generation (kb)
  • DSS: The capacity (kb) of the survivor (survival area) currently needed (the Eden area is full)
  • TT: Limit of holding times
  • MTT: Maximum holding limit

 

4. The command jmap is a multi-functional command. It can generate a dump file of a java program, you can also view the statistical information of the object examples in the heap, view the information of the ClassLoader, and the finalizer queue.

jmap pid view the memory image information of the process, similar to the Solaris pmap command.

jmap -heap pid displays Java heap details
jmap -histo:live pid displays statistics of objects in the heap
jmap -clstats pid prints class loader information

jmap -finalizerinfo pid prints information about objects waiting to be finalized

jmap -dump:format=b,file=heapdump.phrof pid generates heap dump snapshot dump file

5. jinfo is a command that comes with the JDK, which can be used to view the extended parameters of the running java application, including Java System properties and JVM command line parameters; it can also dynamically modify some parameters of the running JVM. When the system crashes, jinfo can know the configuration information of the crashed Java application from the core file

jinfo pid outputs all the parameters and system attributes of the current jvm process

jinfo -flag name pid outputs the parameters of the corresponding name

jinfo -flag [+|-]name pid turns on or off the parameter of the corresponding name

jinfo -flag name=value pid modifies the value of the specified parameter.

jinfo -flags pid outputs all parameters

jinfo -sysprops pid outputs all the system properties of the current jvm

 

Guess you like

Origin blog.csdn.net/A___B___C/article/details/109331996