html
java
算法
jstat [ option ] pid數組
jstat [ option ] executable core服務器
jstat [ option ] [pid] [ server-id@ ] remote-hostname-or-IPoracle
option :命令參數。 pid : 要爲其打印內存映射的進程ID。該進程必須是java進程,可經過jps命 令查看。
(process id for which the memory map is to be printed. The process must be a Java process. To get a list of Java processes running on a machine, jps may be used.) executable:生成核心dump的Java可執行文件。
(Java executable from which the core dump was produced.) core:須要打印配置信息的核心文件。
(core file for which the memory map is to be printed.) server-id:可選的惟一id,若是相同的遠程主機上運行了多臺調試服務器,用此選項參數標識服務器。
(optional unique id, if multiple debug servers are running on the same remote host.) remote-hostname-or-IP:遠程調試服務器的IP地址或主機名。
(remote debug server's (see jsadebugd) hostname or IP address.)
對於目標VM中加載的每一個共享庫,將會打印起始地址,映射的大小以及共享庫文件的完整路徑。這相似於Solaris pmap實用程序。(When no option is used **jmap** prints shared object mappings. For each shared object loaded in the target VM, start address, the size of the mapping, and the full path of the shared object file are printed. This is similar to the Solaris **pmap** utility.)app
從前到後依次爲:共享庫起始地址 映射大小 共享庫文件的完整路徑jvm
[admin@pod-in5kpa01k5 ~]$ jmap -heap 13074 Attaching to process ID 13074, please wait... Debugger attached successfully. Server compiler detected. JVM version is 25.51-b03 using thread-local object allocation. Parallel GC with 4 thread(s) #有兩種組合 其中新生代採用並行處理方式--Parallel Scavenge 收集器 # 老年代可選 -XX:+UseParallelGC -- PSMarkSweep(Serial Old) 串行 # -XX:+UserParallelOldGC -- Parallel Old 並行 Heap Configuration: # 堆配置信息(項目啓動前配置的JVM參數) MinHeapFreeRatio = 0 # -XX:MinHeapFreeRatio 最小空閒比例(default 40) MaxHeapFreeRatio = 100 # -XX:MaxHeapFreeRatio 最大空閒比例(default 70) MaxHeapSize = 2147483648 (2048.0MB) # -XX:MaxHeapSize 堆空間最大大小 NewSize = 715653120 (682.5MB) # -XX:NewSize 新生代默認大小 MaxNewSize = 715653120 (682.5MB) # -XX:MaxNewSize 新生代最大大小 OldSize = 1431830528 (1365.5MB) # -XX:OldSize 老年代默認大小 NewRatio = 2 # -XX:NewRatio 新生代:老年代(不包括永久代),2表示 1:2 SurvivorRatio = 8 # -XX:SurvivorRatio Survivor和Eden的比值,8標識 1:1:8 MetaspaceSize = 268435456 (256.0MB) # 元空間默認大小 CompressedClassSpaceSize = 1073741824 (1024.0MB) # 壓縮類 空間 默認大小 MaxMetaspaceSize = 17592186044415 MB # -XX:MaxMetaspaceSize 元空間最大大小 G1HeapRegionSize = 0 (0.0MB) # 在使用G1垃圾收集器時,JVM會將堆空間分隔爲若干個Region,該參數用來指定每一個Region空間的大小 Heap Usage: # 堆內存實際使用狀況 PS Young Generation # --- 新生代 Eden Space: # Eden空間 capacity = 537395200 (512.5MB) # Eden區總容量 used = 133469040 (127.28599548339844MB) # Eden區已使用 free = 403926160 (385.21400451660156MB) # Eden區剩餘容量 24.83629180163872% used # 使用 百分比 From Space: # From空間 capacity = 89128960 (85.0MB) # From區總容量 used = 40510936 (38.634239196777344MB) # From區已使用 free = 48618024 (46.365760803222656MB) # From區剩餘容量 45.4520461138557% used # 使用 百分比 To Space: # To空間 capacity = 89128960 (85.0MB) # To區總容量 used = 0 (0.0MB) # To區已使用 free = 89128960 (85.0MB) # To區剩餘容量 0.0% used # 使用百分比 PS Old Generation # --- 老年代 capacity = 1431830528 (1365.5MB) # 老年代總空間 used = 180256 (0.171905517578125MB) # 老年代已使用 free = 1431650272 (1365.3280944824219MB) # 老年代剩餘容量 0.01258919938323874% used # 使用 百分比 29573 interned Strings occupying 3039224 bytes.
打印虛擬機內部的類名稱將會帶有一個 * 前綴。(Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes, and fully qualified class names are printed. VM internal class names are printed with '*' prefix.)ide
this
B - byte、C - char、D - double、F - float、I - int、J - long、Z - boolean
[ - 表示數組(如[C 表示 char[])、[L + 類名 表示 其餘對象
對於每一個類加載器,打印其名稱、活躍度、地址、父類加載器 以及它所加載的類的數量和大小(Prints class loader wise statistics of Java heap. For each class loader, its name, how active it is, address, parent class loader, and the number and size of classes it has loaded are printed.)
Number of objects pending for finalization: 0 (等待回收的對象爲0個)
live子選項是可選的。若是指定了live子選項,堆中只有活動的對象會被轉儲。能夠經過jhat打開該文件,經過http去訪問。(Dumps the Java heap in hprof binary format to filename. The live suboption is optional, but when specified, only the active objects in the heap are dumped. To browse the heap dump, you can use the jhat(1) command to read the generated file.)
這個命令執行,JVM會將整個heap的信息dump寫入到一個文件,heap若是比較大的話,就會致使這個過程比較耗時,
而且執行的過程當中爲了保證dump的信息是可靠的,因此會暫停應用, 線上系統慎用。
可強制執行,但指定不正確的端口號時會報錯。只有明確端口號但未響應時纔可以使用。