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的信息是可靠的,因此会暂停应用, 线上系统慎用。
可强制执行,但指定不正确的端口号时会报错。只有明确端口号但未响应时才可以使用。