mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-26 13:48:59 +08:00
Merge pull request #1251 from rishabh-arya95/master
Add support for reading smaps_rollup
This commit is contained in:
commit
f6cc3564ce
@ -380,10 +380,16 @@ func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net
|
||||
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
|
||||
pid := p.Pid
|
||||
var ret []MemoryMapsStat
|
||||
smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps")
|
||||
if grouped {
|
||||
ret = make([]MemoryMapsStat, 1)
|
||||
// If smaps_rollup exists (require kernel >= 4.15), then we will use it
|
||||
// for pre-summed memory information for a process.
|
||||
smapsRollupPath := common.HostProc(strconv.Itoa(int(pid)), "smaps_rollup")
|
||||
if _, err := os.Stat(smapsRollupPath); !os.IsNotExist(err) {
|
||||
smapsPath = smapsRollupPath
|
||||
}
|
||||
}
|
||||
smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps")
|
||||
contents, err := ioutil.ReadFile(smapsPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user