1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 19:32:24 +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,14 +447,18 @@ func startProfiling() (func(), error) {
return nil, err
}
pprof.StartCPUProfile(ofi)
go func() {
for _ = range time.NewTicker(time.Second * 30).C {
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
}
}
}()
stopProfiling := func() {
pprof.StopCPUProfile()
defer ofi.Close() // captured by the closure
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
}
}
return stopProfiling, nil
}
@ -487,7 +491,6 @@ func (ih *IntrHandler) Close() error {
return nil
}
// Handle starts handling the given signals, and will call the handler
// callback function each time a signal is catched. The function is passed
// the number of times the handler has been triggered in total, as