To get a Java heap dump from a Kubernetes container to your local system, first create a dump file inside the pod using a JDK tool like jmap or jcmd. Once the dump file is created, you can copy the file to your local system using the kubectl cp command.
Overview
Java is renowned for its robust garbage collector algorithm, but this doesn’t completely eliminate the risk of memory leaks in JVM applications. To identify potential leaks in your application, the first step is to obtain and analyze a heap dump.
In this short tutorial, we’ll learn how to obtain a Java heap dump from an application running as a Kubernetes pod.
First, we’ll explain the definition of a heap dump, then create a small test application that will be deployed as a pod in Kubernetes. Finally, we’ll walk through the process of obtaining a heap dump from that application.
Continue reading “How to get Java heap dump from Kubernetes container into a local machine?”