简体   繁体   中英

How to get a heap dump from Kubernetes k8s pod?

请提供一个简单的分步指南,以查看来自 Kubernetes pod 的 Java 堆转储。

  1. 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
  1. get the process id (top command)

  2. 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
  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
  1. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM