Added a memprofile dump flag and mechanism

This commit is contained in:
sm
2014-03-08 15:29:08 -08:00
parent 6fd4138740
commit a932d24683
2 changed files with 13 additions and 1 deletions
+11
View File
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"runtime/pprof"
"strings"
)
@@ -202,6 +203,16 @@ func killServer(w http.ResponseWriter, req *http.Request) {
pprof.StopCPUProfile()
log.Print("stopped cpu profile")
}
if *mprofile != "" {
log.Print("trying to dump memory profile")
f, err := os.Create(*mprofile)
if err != nil {
log.Fatal(err)
}
pprof.WriteHeapProfile(f)
f.Close()
log.Print("stopped memory profile dump")
}
log.Fatal("shit got fucked up")
}