mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
write memory profiles every 30 seconds when enabled
This commit is contained in:
@ -447,15 +447,19 @@ func startProfiling() (func(), error) {
|
||||
return nil, err
|
||||
}
|
||||
pprof.StartCPUProfile(ofi)
|
||||
|
||||
stopProfiling := func() {
|
||||
pprof.StopCPUProfile()
|
||||
defer ofi.Close() // captured by the closure
|
||||
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
|
||||
}
|
||||
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
|
||||
|
Reference in New Issue
Block a user