程序啓動時增加如下配置
-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