V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
eightqueen
V2EX  ›  Go 编程语言

gopsutil 获取内存数据误差好大

  •  
  •   eightqueen · 14 天前 · 362 次点击
    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 内存。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1234 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 23:14 · PVG 07:14 · LAX 16:14 · JFK 19:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.