Skip to content

Commit 003bec9

Browse files
committed
Merge pull request google#704 from vmarmol/fix-ws
Fix WorkingSet calculation
2 parents c7908f7 + 757ad9e commit 003bec9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

container/libcontainer/helpers.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,21 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) {
186186
ret.Memory.HierarchicalData.Pgmajfault = v
187187
}
188188
if v, ok := s.MemoryStats.Stats["total_inactive_anon"]; ok {
189-
ret.Memory.WorkingSet = ret.Memory.Usage - v
190-
if v, ok := s.MemoryStats.Stats["total_active_file"]; ok {
191-
ret.Memory.WorkingSet -= v
189+
workingSet := ret.Memory.Usage
190+
if workingSet < v {
191+
workingSet = 0
192+
} else {
193+
workingSet -= v
192194
}
195+
196+
if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
197+
if workingSet < v {
198+
workingSet = 0
199+
} else {
200+
workingSet -= v
201+
}
202+
}
203+
ret.Memory.WorkingSet = workingSet
193204
}
194205
}
195206

0 commit comments

Comments
 (0)