Commit 96fd88e9 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

feat(ipfs2/main) port mem-profiling from previous main

was added 5 days ago in...

https://github.com/jbenet/go-ipfs/commit/7510ef2081e3787e97b815e69a676bd6fc75a9cd
parent 46f1afbe
......@@ -22,12 +22,21 @@ import (
// log is the command logger
var log = u.Logger("cmd/ipfs")
const heapProfile = "ipfs.mprof"
func main() {
args := os.Args[1:]
req, root := createRequest(args)
handleOptions(req, root)
res := callCommand(req, root)
outputResponse(res)
if u.Debug {
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
}
}
}
func createRequest(args []string) (cmds.Request, *cmds.Command) {
......@@ -232,3 +241,12 @@ func getConfig(path string) (*config.Config, error) {
return config.Load(configFile)
}
func writeHeapProfileToFile() error {
mprof, err := os.Create(heapProfile)
if err != nil {
log.Fatal(err)
}
defer mprof.Close()
return pprof.WriteHeapProfile(mprof)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment