package subject import ( "fmt" "runtime" ) func toMegaBytes(bytes uint64) float64 { return float64(bytes) / 1024 / 1024 } func traceMemStats() { var ms runtime.MemStats runtime.ReadMemStats(&ms) var result = make([]float64, 7) result[0] = float64(ms.HeapObjects) result[1] = toMegaBytes(ms.HeapAlloc) result[2] = toMegaBytes(ms.TotalAlloc) result[3] = toMegaBytes(ms.HeapSys) result[4] = toMegaBytes(ms.HeapIdle) result[5] = toMegaBytes(ms.HeapReleased) result[6] = toMegaBytes(ms.HeapIdle - ms.HeapReleased) for _, v := range result { fmt.Printf("%.2f\t", v) } fmt.Printf("\n") }