1.执行jcmd命令生成文件
jcmd <pid> GC.heap_dump <file-path>
例如:jcmd 1234 GC.heap_dump /tmp/dump.hprof
2.执行kubectl命令下载文件到本地
k8s容器拷贝文件到本地
kubectl cp order-b477c8947-tr8rz:/tmp/dump.hprof /root/test/dump.hprof
本地文件拷贝到k8s容器
tar cf - data.txt | kubectl exec -i -n qzcsbj order-b477c8947-tr8rz -- tar xf - -C /root/
3.打开hprof文件
打开jdk目录下 jvisualvm.exe
打开本地的文件, 就可以查看 hprof文件内容了