The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
eightqueen

gopsutil 获取内存数据误差好大

  •  
  •   eightqueen · May 14, 2024 · 1091 views
    This topic created in 766 days ago, the information mentioned may be changed or developed.
    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 内存。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   946 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:00 · PVG 03:00 · LAX 12:00 · JFK 15:00
    ♥ Do have faith in what you're doing.