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

gopsutil 获取内存数据误差好大

  •  
  •   eightqueen · May 14, 2024 · 1362 views
    This topic created in 912 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   ·   Privacy   ·   Solana   ·   975 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 22:03 · PVG 06:03 · LAX 14:03 · JFK 17:03
    ♥ Do have faith in what you're doing.