Skip to content

Commit

Permalink
cmd/covdata: close cpu and mem profile
Browse files Browse the repository at this point in the history
Change-Id: Iaf14989eb2981f724c4091f992ed99687ce3a60e
GitHub-Last-Rev: 6e6c82b
GitHub-Pull-Request: #66852
Reviewed-on: https://go-review.googlesource.com/c/go/+/579255
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
Auto-Submit: Than McIntosh <[email protected]>
  • Loading branch information
testwill authored and pull[bot] committed Dec 28, 2024
1 parent b86b0f4 commit 2499fb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cmd/covdata/covdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ func main() {
if err := pprof.StartCPUProfile(f); err != nil {
fatal("%v", err)
}
atExit(pprof.StopCPUProfile)
atExit(func() {
pprof.StopCPUProfile()
if err = f.Close(); err != nil {
fatal("error closing cpu profile: %v", err)
}
})
}
if *memprofileflag != "" {
if *memprofilerateflag != 0 {
Expand All @@ -192,6 +197,9 @@ func main() {
if err := pprof.Lookup("heap").WriteTo(f, writeLegacyFormat); err != nil {
fatal("%v", err)
}
if err = f.Close(); err != nil {
fatal("error closing memory profile: %v", err)
}
})
} else {
// Not doing memory profiling; disable it entirely.
Expand Down

0 comments on commit 2499fb3

Please sign in to comment.