<p>I'm trying to get a breakdown of the memory usage of my pods running on Kubernetes. I can see the pod's memory usage through <code>kubectl top pod</code> but what I need is a total breakdown of where the memory is used.</p>

<p>My container might download or write new files to disk, so I'd like to see at a certain moment how much of the used memory is used for each file and how much is used by software running.
currently, there's no real disk but just the TempFS, so that means every file is consuming the allocated memory resources, that is okay as long as I can inspect and know how much memory is where.</p>

<p>Couldn't find anything like that, it seems that <code>cAdvisor</code> helps to get memory statics but it just uses <code>docker/cgroups</code> which doesn't give a breakdown as I described.</p>

<p>A better solution would be to install a metrics server along with <a href="https://prometheus.io/docs/guides/cadvisor/" rel="nofollow noreferrer">Prometheus</a> and Grafana in your cluster. Prometheus will <strong>scrape</strong> the metrics which can be used by Grafana for displaying as graphs. This might be useful.</p>
<p>If you want the processes consumption inside the container, you can go into the container and monitor the processes.</p>
<pre><code>$ docker exec -it &lt;container-name&gt; watch ps -aux
</code></pre>
<p>Moreover, you can check <a href="https://docs.docker.com/engine/reference/commandline/stats/" rel="nofollow noreferrer">docker stats</a>.</p>
<p>Following Linux command will summarize the sizes of the directories:</p>
<pre><code>$ du -h
</code></pre>
