Skip to content

Taking Java Memory Dump from Containerized App running in AKS/K8S

Notifications You must be signed in to change notification settings

easonlai/aks-java-alpine-openjdk-memory-dump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Taking Java Memory Dump from Containerized App running in AKS/K8S

Special tricks to take Java memory dump from Alpine (e.g. OpenJDK-Alpine) based container which running in Azure Kubernetes Service (AKS). By adding Tini as init of container, otherwise Java process in Alpine would be using PID 1 and would make "Unable to get pid of LinuxThreads manager thread" error when taking Java memory dump (same to jcmd, jstack).

Get list of POD running in AKS.

kubectl get pod

Run interactive terminal from container POD.

kubectl exec -it your-java-app-pod-name /bin/sh

Check Process ID (PID) running Java. PID not equal to 1 should be our target to take memory dump.

top

Start to take memory dump.

cd /tmp
jmap -dump:format=b,file=snapshot.jmap 1
exit

Copy out memory dump from container to your development machine.

kubectl cp your-java-app-pod-name:tmp/snapshot.jmap snapshot.jmap -n your-pod-namespace