Today I stumbled upon a Java memory Detection tool: Jstat
A search on the Internet, the parameters are as follows
Used to determine if there is a memory problem with the JVM. How to determine if the JVM garbage collection is normal. The general top directive basically doesn't meet this requirement because it mainly monitors the overall system resources and it is difficult to locate Java applications. Jstat is a lightweight gadget with JDK. Full name "Java virtual machine statistics monitoring tool", which is located in the Java bin directory, The main use of the JVM's built-in directives for real-time command-line monitoring of the resources and performance of Java applications, including monitoring of heap size and garbage collection status. Visible, Jstat is a lightweight, JVM-specific tool that works well. Because of the large JVM memory settings, the percentage change in the graph is less obvious a strong monitoring VM memory tool. can be used to monitor the size and memory usage of various heaps and heaps within the VM's memory. The Jstat tool is particularly powerful, with numerous options for detailed viewing of the usage of each part of the heap and the number of load classes. When used, you need to add the process ID of the view process, and the selected parameters. Execute:cd $JAVA _home/bin execute jstat, note Jstat must follow the parameters. jstat : monitoring VM memory usage. jstat tools are particularly powerful, with numerous options for looking at the amount of usage in each part of the heap and the number of load classes. When used, you need to add the process ID of the view process, and the selected parameters. The meaning of each parameter is described in detail below. jstat -class pid: Displays the number of loaded classes, and the space occupied and other information. jstat -compiler pid: Displays information such as the number of real-time VM compilations. jstat -gc pid: You can display GC information, view the number of GC, and time. The last five items, respectively, are YOUNG&NBSP;GC times, young gc time, FULL&NBSP;GC times, FULL&NBSP;GC time, GC total time. jstat -gccapacity: Can show the use and occupancy of three generations (Young,old,perm) objects in VM memory, For example: PGCMN Displays the minimum perm memory usage, PGCMX displays the maximum amount of memory used by Perm, and PGC is the currently generated perm memory footprint, and the PC is the previous Perm memory footprint. Other can be based on this analogy, &NBSP;OC is the pure amount of old. jstat -gcnew pid:new object information. jstat -gcnewcapacity pid:new The object's information and how much it occupies. jstat -gcold pid:old object information. jstat -gcoldcapacity pid:old The object's information and how much it occupies. jstat -gcpermcapacity pid: perm The object's information and how much it occupies. &NBSP;&NBSP;&NBSP;&NBSP;JSTAT&NBSP;-UTIL&NBSP;PID: Statistical GC information statistics. jstat -printcompilation pid: Information on current VM execution. In addition to one of the above parameters, can also add two numbers, such as: jstat -printcompilation 3024 250 6 is printed every 250 milliseconds, printed 6 times, and can be added-h3 every three lines to show the title. Grammatical structure: usage: jstat -help|-options jstat -<option> [-t] [-h< lines>] <vmid> [<interval> [<count>]] Parameter explanation: options - option, we generally use -gcutil view GC situation Vmid &NBSP;&NBSP;&NBSP;&NBSP;-&NBSP;VM process number, that is, the currently running Java process number interval– interval, in seconds or milliseconds count - printing times, if the default is printed countless times s0 - Survivor space 0 on heap% of used space survivor on S1 - heap space 1 percentage of used space E - heap Eden space Percentage of space already used o - heap on olPercentage of space used in the d space area percentage of space used in p - perm space area ygc - number of Young GC occurrences from application startup to sampling ygct– from application startup to sampling &NBSP;YOUNG&NBSP;GC Time (in seconds) fgc - from application startup to sampling Full GC fgct– Time spent in Full GC (in seconds) from application startup to sampling gct - total time for garbage collection from application startup to sampling (in seconds) instance use 1: [root@localhost bin]# jstat -gcutil 25444 S0 S1 E O P YGC YGCT FGC FGCT GCT 11.63 0.00 56.46 66.92 98.49 162 0.248 6 0.331 0.579 Instance use 2: (25444 is the Java process number, Ps -ef | grep java) [root@localhost bin]# jstat -gcutil 25444 1000 5 S0 S1 E O P YGC ygct fgc fgct gct 73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583 73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583 73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583 73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583 73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583 we can see that 5 times young After GC, the garbage memory is removed from the Eden spacArea e (E) was placed in the Old space area (O) and caused a change in the percentage, resulting in a decrease in the percentage of survivor space used from 73.54% (S0) to 0% (S1). Effectively frees up memory space. In the green box, we can see that after a FULL&NBSP;GC, the memory of the Old space area (O) is recycled from 99.05% to 67.52%.