JVM 查看堆和GC信息的方式(How the JVM views heap and GC information)

1. JVM 参数

-XX:ErrorFile=D:/data/logs/hs_err.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:/data/logs/heap_dump.hprof -Xloggc:D:/data/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC

2. 查看 dump 文件工具

https://www.eclipse.org/mat/previousReleases.php
注意要与jdk版本对应

3. 用命令导出 dump 文件

  • 查看端口号:jps
  • 导出文件:jmap -dump:format=b,file=D:\data\dump.hprof {端口号}
————————

1. JVM parameters

-XX:ErrorFile=D:/data/logs/hs_err.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:/data/logs/heap_dump.hprof -Xloggc:D:/data/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintClassHistogramBeforeFullGC -XX:+PrintClassHistogramAfterFullGC

2. View dump file tool

https://www.eclipse.org/mat/previousReleases.php
注意要与jdk版本对应

3. Export dump file with command

  • View port number: JPS
  • 导出文件:jmap -dump:format=b,file=D:\data\dump.hprof {端口号}