sreroot

Runbooks / High memory

\n

High memory

\n

Kubernetes · Java · incident notes

\n
\n

Purpose

\n

Investigate high memory usage, OOMKills, container restarts, and possible Java heap or native-memory leaks.

\n

Symptoms

\n\n

Initial Triage

\n
kubectl top pods -n <namespace> --sort-by=memory\nkubectl describe pod <pod> -n <namespace>\nkubectl get events -n <namespace> --sort-by=.lastTimestamp\nkubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}'
\n

Check configured resources:

\n
kubectl get deploy <deployment> -n <namespace> -o yaml
\n

Compare:

\n\n

JVM Memory Checks

\n
kubectl exec -n <namespace> <pod> -- jcmd <java-pid> VM.flags\nkubectl exec -n <namespace> <pod> -- jcmd <java-pid> GC.heap_info\nkubectl exec -n <namespace> <pod> -- jcmd <java-pid> VM.native_memory summary
\n

Native Memory Tracking must be enabled at JVM startup for detailed output:

\n
-XX:NativeMemoryTracking=summary
\n

Check GC logs for:

\n\n

Heap Dump

\n

Only capture a heap dump after assessing disk capacity and operational impact:

\n
kubectl exec -n <namespace> <pod> -- jcmd <java-pid> GC.heap_dump /tmp/heap.hprof\nkubectl cp <namespace>/<pod>:/tmp/heap.hprof ./heap.hprof
\n

Analyze with Eclipse MAT or another approved heap-analysis tool.

\n

Look for:

\n\n

Common Causes

\n\n

Mitigation

\n\n

Validation

\n
kubectl top pod <pod> -n <namespace>\nkubectl get pod <pod> -n <namespace> -w
\n

Confirm:

\n\n