pprof的inuse_space和linux top查看的RES差别很大

njuyang14 · · 1741 次点击
送你一段代码,RES是这么算的 RES=HeapInuse + HeapIdle - HeapReleased ``` package main import ( "fmt" "runtime" "time" ) func main() { fmt.Printf("%v\t%v\t%v\t%v\n", "HeapInuse", "HeapIdle", "HeapReleased", "RES") for i := 0; i < 200; i++ { _ = make([]int, i*1000000) m := runtime.MemStats{} runtime.ReadMemStats(&m) fmt.Printf("%v\t%v\t%v\t%v\n", m.HeapInuse, m.HeapIdle, m.HeapReleased, m.HeapInuse + m.HeapIdle - m.HeapReleased) time.Sleep(time.Second) } } ```
#1