文档

为什么在容器中得到的内存值不一致?

更新时间:

Pod命令如何计算内存使用量

执行kubectl top pod命令得到的结果,并不是容器服务中container_memory_usage_bytes指标的内存使用量,而是指标container_memory_working_set_bytes的内存使用量,计算方法如下:

  • container_memory_usage_bytes = container_memory_rss + container_memory_cache + kernel memory

  • container_memory_working_set_bytes = container_memory_usage_bytes - total_inactive_file(未激活的匿名缓存页)

container_memory_working_set_bytes是容器真实使用的内存量,也是资源限制limit时的重启判断依据。