0

I have a sidecar container with the following resources:

resources:
  limits:
    memory: 512Mi
  requests:
    memory: 64Mi

However, when I run top, I see this:

  • envoy & pilot-agent seem to be using ~ 363MB & 61MB respectively
  • used memory at the top is 54.6MB
  • running free -m gives the following; a seemingly uncorrelated answer
$ free -m
              total        used        free      shared  buff/cache   available
Mem:         385307       47140      315018         292       23148      336021
Swap:             0           0           0

top running in a sidecar

What exactly is going on here, and how much memory are those processes consuming?

Jon Bates
  • 107
  • 5

1 Answers1

1

That free and top output is showing about 50,000 MiB used, of a host with about 385,000 MiB memory total.

Containers share a kernel, so host metrics will generally show node wide numbers. Even though namespaces only show your processes and files. This is different from a dedicated VM or physical host, where the operating system only exists to support your application.

Per container numbers requires querying the cgroups numbers. See a few ways to do so over on Stack Overflow: Checking kubernetes pod CPU and memory. Many of which require metrics server.

Beware adding up RESident memory of processes and expecting that to be the exact memory use of the system. This does not include shared memory or caches. And the kernel does weird accounting tricks with memory. Your 3 significant digits is the right idea. Although, in the simple case of a small number of processes, using primarily private memory, its a good estimate.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34