What is the relation between `container_memory_working_set_bytes` metric and OOM-killer on the container? What is the relation between `container_memory_working_set_bytes` metric and OOM-killer on the container? kubernetes kubernetes

What is the relation between `container_memory_working_set_bytes` metric and OOM-killer on the container?


As you already know, container_memory_working_set_bytes is:

the amount of working set memory and it includes recently accessedmemory, dirty memory, and kernel memory. Therefore, Working set is(lesser than or equal to) </= "usage".

The container_memory_working_set_bytes is being used for OoM decisions because it excludes cached data (Linux Page Cache) that can be evicted in memory pressure scenarios.

So, if the container_memory_working_set_bytes is increased to the limit, it will lead to oomkill.

You can find the fact that when Linux kernel checking available memory, it calls vm_enough_memory() to find out how many pages are potentially available.

Then when the machine is low on memory, old page frames including cache will be reclaimed but kernel still may find that it was unable free enough pages to satisfy a request. Now it's time to call out_of_memory() to kill the process. To determine the candidate process to be killed it uses oom_score.

So when Working Set bytes reached to limits, it means that kernel cannot find availables pages even after reclaiming old pages including cache so kernel will trigger OOM-killer to kill the process.

You can find more details on the Linux kernel documents: