Added a memprofile dump flag and mechanism
This commit is contained in:
+11
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user