mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
fix slice indices
This commit is contained in:
parent
47166d6a81
commit
29b3c3719b
@ -603,16 +603,16 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M
|
|||||||
return &ret, err
|
return &ret, err
|
||||||
}
|
}
|
||||||
if grouped {
|
if grouped {
|
||||||
ret.Size += g.Size
|
ret[0].Size += g.Size
|
||||||
ret.Rss += g.Rss
|
ret[0].Rss += g.Rss
|
||||||
ret.Pss += g.Pss
|
ret[0].Pss += g.Pss
|
||||||
ret.SharedClean += g.SharedClean
|
ret[0].SharedClean += g.SharedClean
|
||||||
ret.SharedDirty += g.SharedDirty
|
ret[0].SharedDirty += g.SharedDirty
|
||||||
ret.PrivateClean += g.PrivateClean
|
ret[0].PrivateClean += g.PrivateClean
|
||||||
ret.PrivateDirty += g.PrivateDirty
|
ret[0].PrivateDirty += g.PrivateDirty
|
||||||
ret.Referenced += g.Referenced
|
ret[0].Referenced += g.Referenced
|
||||||
ret.Anonymous += g.Anonymous
|
ret[0].Anonymous += g.Anonymous
|
||||||
ret.Swap += g.Swap
|
ret[0].Swap += g.Swap
|
||||||
} else {
|
} else {
|
||||||
ret = append(ret, g)
|
ret = append(ret, g)
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,14 @@ func Test_Process_memory_maps(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// grouped memory maps
|
// grouped memory maps
|
||||||
mmaps, err := ret.MemoryMaps(true)
|
mmaps, err = ret.MemoryMaps(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("memory map get error %v", err)
|
t.Errorf("memory map get error %v", err)
|
||||||
}
|
}
|
||||||
if len(mmaps) != 1 {
|
if len(*mmaps) != 1 {
|
||||||
t.Errorf("grouped memory maps length (%v) is not equal to 1", len(mmaps))
|
t.Errorf("grouped memory maps length (%v) is not equal to 1", len(*mmaps))
|
||||||
}
|
}
|
||||||
if mmaps[0] == empty {
|
if (*mmaps)[0] == empty {
|
||||||
t.Errorf("memory map is empty")
|
t.Errorf("memory map is empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user