kubernetes: kubelet reports wrong memory usage on Windows
What happened?
kubelet calculates memory usage in a different way:
memUsage = "WorkingSet - Private" / TotalPhysicalMemory
'WorkingSet - Private" is physical memory used by all the processes, it does not include “cached” memory used by FileSystem.
What did you expect to happen?
kubelet takes account of cached memory.
How can we reproduce it (as minimally and precisely as possible)?
create a windows node with 8G memory, write an application to consume 8G memory, then you will find(almost all the memory are used, but kubelet reports 532MB only, that is not expected.):

Anything else we need to know?
No response
Kubernetes version
$ kubectl version
# paste output here
Cloud provider
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 25 (11 by maintainers)
/remove-lifecycle rotten
In v1.31 we added information about the node’s global commit memory usage which in many cases is more useful compared to
Working Set - Privatebytes on Windows Currently the only thing consumes this information is the eviction manager but possibly we can update things likekubectl top nodeto use memory commit information on nodes running v1.31+I think we want the entire “Private Bytes” reported instead, rather than adding cached. What windows is saying here is that the application was swapped to virtual memory but immediately cached in memory. This is a Windows performance optimisation that allows it to swap to disk quickly if needed. The values would be correct without any swap enabled however.
Do we really need to report cached memory? The vritual memory subsystem will reclaim cached pages as memory pressure increases, just as it does in Linux.
For comparison, here’s my Linux box with 40Gi of cached memory usage. We wouldn’t report on kubelet that 54Gi of RAM is in use for the same reason.