1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 09:52:20 +08:00

write memory profiles every 30 seconds when enabled

This commit is contained in:
Jeromy
2015-04-27 15:26:58 -07:00
parent fcb559eb9d
commit dff606a347

View File

@ -447,15 +447,19 @@ func startProfiling() (func(), error) {
return nil, err return nil, err
} }
pprof.StartCPUProfile(ofi) pprof.StartCPUProfile(ofi)
go func() {
stopProfiling := func() { for _ = range time.NewTicker(time.Second * 30).C {
pprof.StopCPUProfile()
defer ofi.Close() // captured by the closure
err := writeHeapProfileToFile() err := writeHeapProfileToFile()
if err != nil { if err != nil {
log.Critical(err) log.Critical(err)
} }
} }
}()
stopProfiling := func() {
pprof.StopCPUProfile()
defer ofi.Close() // captured by the closure
}
return stopProfiling, nil return stopProfiling, nil
} }
@ -487,7 +491,6 @@ func (ih *IntrHandler) Close() error {
return nil return nil
} }
// Handle starts handling the given signals, and will call the handler // Handle starts handling the given signals, and will call the handler
// callback function each time a signal is catched. The function is passed // callback function each time a signal is catched. The function is passed
// the number of times the handler has been triggered in total, as // the number of times the handler has been triggered in total, as