英文:
How to get a heap dump from Kubernetes k8s pod?
问题
请提供一个简单的逐步指南,以查看来自Kubernetes pod的Java堆转储(heap dump)。
英文:
Please provide a simple step by step guide to looking into java heap dump from a Kubernetes pod.
答案1
得分: 24
- 登录到 K8S 并进入运行你的 Java 应用程序的 Pods。
kubectl exec -it herle-deployment-pod-5757d89d85-wrpc9 bash
-
获取进程 ID(使用 top 命令)。
-
创建 Java 堆转储文件。
jmap -dump:live,format=b,file=<file_name>.bin <process_id>
示例:
jmap -dump:live,format=b,file=application_heap_dump.bin 1
- 将堆转储文件从 Pod 复制到本地机器。
kubectl cp <pod_name>:<heap_file> <your_local_destination_directory>
示例:
kubectl cp herle-deployment-pod-5757d89d85-wrpc9:/tmp/application_heap_dump.bin /Users/amritharajherle/Desktop/application_heap_dump.bin
英文:
- Log in to the K8S and exec into the Pods where your java application is running.
kubectl exec -it herle-deployment-pod-5757d89d85-wrpc9 bash
-
get the process id (top command)
-
Create java heap dump
jmap -dump:live,format=b,file=<file_name>.bin <process_id>
Example:
jmap -dump:live,format=b,file=application_heap_dump.bin 1
- Copy the heap dump from pod to your local machine.
kubectl cp <pod_name>:<heap_file> <your local destination directory>
Example:
kubectl cp herle-deployment-pod-5757d89d85-wrpc9:/tmp/application_heap_dump.bin /Users/amritharajherle/Desktop/application_heap_dump.bin
- Use any memory leak analysis tool. I'm using the Eclipse's Memory Analyzer plugin.
- Open the heap dump file
- select leak suspect report
- You can check the number of objects and retained heap space. Also some possible leak suspects.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论