Skip to content

Commit 0f754f0

Browse files
authored
fix(clistat): do not include buffers/cache for host memory used (#8095)
1 parent 06a5e24 commit 0f754f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cli/clistat/stat.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ func (s *Statter) HostMemory() (*Result, error) {
186186
return nil, xerrors.Errorf("get memory info: %w", err)
187187
}
188188
r.Total = ptr.To(float64(hm.Total))
189-
r.Used = float64(hm.Used)
189+
// On Linux, hm.Used equates to MemTotal - MemFree in /proc/stat.
190+
// This includes buffers and cache.
191+
// So use MemAvailable instead, which only equates to physical memory.
192+
// On Windows, this is also calculated as Total - Available.
193+
r.Used = float64(hm.Total - hm.Available)
190194
return r, nil
191195
}

0 commit comments

Comments
 (0)