summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-03-26 15:32:53 -0700
committerRuss Cox <rsc@golang.org>2010-03-26 15:32:53 -0700
commitb08838750c92828a3fbb912256585fe3c6453c54 (patch)
treeec36601ae8c6d7fc103d79e75cba390362b0c77c
parent5926c45477c5e4cc35f93069fc7dbdaa199aae8a (diff)
downloadgolang-b08838750c92828a3fbb912256585fe3c6453c54.tar.gz
pprof: dump extra heap information at end of heap profile
R=r CC=golang-dev http://codereview.appspot.com/786041
-rw-r--r--src/pkg/runtime/pprof/pprof.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/pkg/runtime/pprof/pprof.go b/src/pkg/runtime/pprof/pprof.go
index 143c3c65c..71bca1e07 100644
--- a/src/pkg/runtime/pprof/pprof.go
+++ b/src/pkg/runtime/pprof/pprof.go
@@ -69,5 +69,29 @@ func WriteHeapProfile(w io.Writer) os.Error {
}
fmt.Fprintf(b, "\n")
}
+
+ // Print memstats information too.
+ // Pprof will ignore, but useful for people.
+ s := &runtime.MemStats
+ fmt.Fprintf(b, "\n# runtime.MemStats\n")
+ fmt.Fprintf(b, "# Alloc = %d\n", s.Alloc)
+ fmt.Fprintf(b, "# TotalAlloc = %d\n", s.TotalAlloc)
+ fmt.Fprintf(b, "# Sys = %d\n", s.Sys)
+ fmt.Fprintf(b, "# Stacks = %d\n", s.Stacks)
+ fmt.Fprintf(b, "# InusePages = %d\n", s.InusePages)
+ fmt.Fprintf(b, "# NextGC = %d\n", s.NextGC)
+ fmt.Fprintf(b, "# HeapAlloc = %d\n", s.HeapAlloc)
+ fmt.Fprintf(b, "# Lookups = %d\n", s.Lookups)
+ fmt.Fprintf(b, "# Mallocs = %d\n", s.Mallocs)
+ fmt.Fprintf(b, "# PauseNs = %d\n", s.PauseNs)
+ fmt.Fprintf(b, "# NumGC = %d\n", s.NumGC)
+ fmt.Fprintf(b, "# EnableGC = %v\n", s.EnableGC)
+ fmt.Fprintf(b, "# DebugGC = %v\n", s.DebugGC)
+ fmt.Fprintf(b, "# BySize = Size * (Active = Mallocs - Frees)\n")
+ for _, t := range s.BySize {
+ if t.Mallocs > 0 {
+ fmt.Fprintf(b, "# %d * (%d = %d - %d)\n", t.Size, t.Mallocs-t.Frees, t.Mallocs, t.Frees)
+ }
+ }
return b.Flush()
}