程序启动时增加如下配置
-Djava.rmi.server.hostname=ip
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.rmi.port=7098
-Dcom.sun.management.jmxremote.port=7099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof
jar 程序启动命令
java
-Djava.rmi.server.hostname=ip
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.rmi.port=7098
-Dcom.sun.management.jmxremote.port=7099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof
-jar
xxx.jar
7098 为 jstatd 链接
7099 为 jmx 链接
docker 中启动也需要带入JVM参数,并且将 7098,7099端口映射到外部即可
内存泄露设置错误记录文件位置及文件名
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof