summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-24 10:58:13 -0400
committerRuss Cox <rsc@golang.org>2014-10-24 10:58:13 -0400
commit578a3be106fc48e66f780e736fdf5a486236c2ab (patch)
tree95441985e09057ca9ddfa57e9bd279e93251575d /src/net
parent135abd769e17b88c2bb8fde4b5963b71c582ea0f (diff)
downloadgo-578a3be106fc48e66f780e736fdf5a486236c2ab.tar.gz
net/http/pprof: run GC for /debug/pprof/heap?gc=1
We force runtime.GC before WriteHeapProfile with -test.heapprofile. Make it possible to do the same with the HTTP interface. Some servers only run a GC every few minutes. On such servers, the heap profile will be a few minutes stale, which may be too old to be useful. Requested by private mail. LGTM=dvyukov R=dvyukov CC=golang-codereviews https://codereview.appspot.com/161990043
Diffstat (limited to 'src/net')
-rw-r--r--src/net/http/pprof/pprof.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/net/http/pprof/pprof.go b/src/net/http/pprof/pprof.go
index 0c7548e3e..a23f1bc4b 100644
--- a/src/net/http/pprof/pprof.go
+++ b/src/net/http/pprof/pprof.go
@@ -162,6 +162,10 @@ func (name handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Unknown profile: %s\n", name)
return
}
+ gc, _ := strconv.Atoi(r.FormValue("gc"))
+ if name == "heap" && gc > 0 {
+ runtime.GC()
+ }
p.WriteTo(w, debug)
return
}