From dff606a34750139cc5ade530e5f3cadcd4e9c042 Mon Sep 17 00:00:00 2001 From: Jeromy <jeromyj@gmail.com> Date: Mon, 27 Apr 2015 15:26:58 -0700 Subject: [PATCH] write memory profiles every 30 seconds when enabled --- cmd/ipfs/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 2ad90cfc1..998effcd9 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -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 -- GitLab