From 7ea1d0dd478b8e95a9797c5622a03f06d4efb3ce Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:26:20 -0700 Subject: [PATCH] Fix calculation for docker container memory usage (#2167) --- src/widgets/docker/stats-helpers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/docker/stats-helpers.js b/src/widgets/docker/stats-helpers.js index 13c689632..186205858 100644 --- a/src/widgets/docker/stats-helpers.js +++ b/src/widgets/docker/stats-helpers.js @@ -11,5 +11,6 @@ export function calculateCPUPercent(stats) { } export function calculateUsedMemory(stats) { - return stats.memory_stats.usage - (stats.memory_stats.stats.cache ?? 0) + // see https://github.com/docker/cli/blob/dcc161076861177b5eef6cb321722520db3184e7/cli/command/container/stats_helpers.go#L239 + return stats.memory_stats.usage - (stats.memory_stats.total_inactive_file ?? stats.memory_stats.stats.inactive_file ?? 0) } \ No newline at end of file