package main
import (
"fmt"
"
github.com/shirou/gopsutil/process"
)
func main() {
p, _ := process.NewProcess(926)
fmt.Println(p.Cmdline())
memInfo, _ := p.MemoryInfo()
memPercent, _ := p.MemoryPercent()
fmt.Println(memInfo)
fmt.Printf("rss: %dM, percent: %f\n", memInfo.RSS/1024/1024, memPercent)
}
输出:{"rss":239845376,"vms":436334346240,"hwm":0,"data":0,"stack":0,"locked":0,"swap":0}
rss: 228M, percent: 0.698042
但是 mac 的活动监视器里显示该进程占用 842M 内存。