Skip to content

Commit fc28ef4

Browse files
committedMay 2, 2015
Merge pull request #1149 from ipfs/fix/better-mem-prof
write memory profiles every 30 seconds when enabled
2 parents 2d3fb84 + dff606a commit fc28ef4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎cmd/ipfs/main.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,18 @@ func startProfiling() (func(), error) {
453453
return nil, err
454454
}
455455
pprof.StartCPUProfile(ofi)
456+
go func() {
457+
for _ = range time.NewTicker(time.Second * 30).C {
458+
err := writeHeapProfileToFile()
459+
if err != nil {
460+
log.Critical(err)
461+
}
462+
}
463+
}()
456464

457465
stopProfiling := func() {
458466
pprof.StopCPUProfile()
459467
defer ofi.Close() // captured by the closure
460-
err := writeHeapProfileToFile()
461-
if err != nil {
462-
log.Critical(err)
463-
}
464468
}
465469
return stopProfiling, nil
466470
}

0 commit comments

Comments
 (0)
Please sign in to comment.