mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 09:59:13 +08:00
Merge pull request #1149 from ipfs/fix/better-mem-prof
write memory profiles every 30 seconds when enabled
This commit is contained in:
@ -453,14 +453,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
|
||||
}
|
||||
|
Reference in New Issue
Block a user