write memory profiles every 30 seconds when enabled
Jeromy committed
Apr 27, 2015 at 15:26 UTC
dff606a34750139cc5ade530e5f3cadcd4e9c042
1 file changed
+8
-5
cmd/ipfs/main.go
+8
-5
@@ -447,14 +447,18 @@ func startProfiling() (func(), error) {
447
return nil, err
448
}
449
pprof.StartCPUProfile(ofi)
450
+ go func() {
451
+ for _ = range time.NewTicker(time.Second * 30).C {
452
+ err := writeHeapProfileToFile()
453
+ if err != nil {
454
+ log.Critical(err)
455
+ }
456
+ }
457
+ }()
458
459
stopProfiling := func() {
460
pprof.StopCPUProfile()
461
defer ofi.Close() // captured by the closure
454
- err := writeHeapProfileToFile()
455
- if err != nil {
456
- log.Critical(err)
457
- }
462
}
463
return stopProfiling, nil
464
}
@@ -487,7 +491,6 @@ func (ih *IntrHandler) Close() error {
491
return nil
492
}
493
490
-
494
// Handle starts handling the given signals, and will call the handler
495
// callback function each time a signal is catched. The function is passed
496
// the number of times the handler has been triggered in total, as