<p>Please provide a simple step by step guide to looking into java heap dump from a Kubernetes pod.</p>

Amrith Raj Herle
<ol>
<li>Log in to the K8S and exec into the Pods where your java application is running.</li>
</ol>
<pre><code>kubectl exec -it herle-deployment-pod-5757d89d85-wrpc9 bash
</code></pre>
<ol start="2">
<li><p>get the process id (top command)</p>
</li>
<li><p>Create java heap dump</p>
</li>
</ol>
<pre><code>jmap -dump:live,format=b,file=&lt;file_name&gt;.bin &lt;process_id&gt;
</code></pre>
<p>Example:</p>
<pre><code>jmap -dump:live,format=b,file=application_heap_dump.bin 1
</code></pre>
<ol start="4">
<li>Copy the heap dump from pod to your local machine.</li>
</ol>
<pre><code>kubectl cp &lt;pod_name&gt;:&lt;heap_file&gt; &lt;your local destination directory&gt;
</code></pre>
<p>Example:</p>
<pre><code>kubectl cp herle-deployment-pod-5757d89d85-wrpc9:/tmp/application_heap_dump.bin /Users/amritharajherle/Desktop/application_heap_dump.bin
</code></pre>
<ol start="5">
<li>Use any memory leak analysis tool. I'm using the Eclipse's <strong>Memory Analyzer</strong> plugin.</li>
</ol>
<ul>
<li>Open the heap dump file</li>
</ul>
<p><a href="https://i.stack.imgur.com/4tLfh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4tLfh.png" alt="Open the heap dump file" /></a></p>
<ul>
<li>select leak suspect report</li>
</ul>
<p><a href="https://i.stack.imgur.com/EGvxh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EGvxh.png" alt="select leak suspects report" /></a></p>
<ul>
<li>You can check the number of objects and retained heap space. Also some possible leak suspects.</li>
</ul>
