1

While running a Python service in Kubernetes (pod with just one container, my Gunicorn process has PID 1), I monitor the memory usage:

psutil.Process().memory_full_info()

output:

pfullmem(rss=669609984, vms=5986619392, shared=229244928, text=4096, lib=0, data=3318370304, dirty=0, uss=658903040, pss=664651776, swap=0)

However, cgroups (which Kubernetes uses to decide when to OOM-kill a pod)

cat /sys/fs/cgroup/memory.current

shows (at the same time):

474193920

So it does not correspond to any of the values shown by psutil.

Where the difference comes from?

Tobias Hermann
  • 9,936
  • 6
  • 61
  • 134
  • 1
    This question might help https://stackoverflow.com/questions/46212787/how-to-correctly-report-available-ram-within-a-docker-container#:~:text=Docker%20uses%20CGroups%20to%20control%20resource%20usage%20by,%2Fproc%2Fmeminfo%20file%20which%20shows%20system%27s%2C%20not%20container%2C%20capabilities. – mercurial Aug 08 '23 at 04:14

0 Answers0