mirror of https://github.com/golang/go.git
cmd/compile: close files in the startProfile function
Change-Id: I803d625249890c88fbf35394a85e0b2952123620
GitHub-Last-Rev: 239b28e857
GitHub-Pull-Request: golang/go#66532
Reviewed-on: https://go-review.googlesource.com/c/go/+/574336
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
7c89ad6a80
commit
a49952445f
|
|
@ -39,7 +39,12 @@ func startProfile() {
|
|||
if err := pprof.StartCPUProfile(f); err != nil {
|
||||
base.Fatalf("%v", err)
|
||||
}
|
||||
base.AtExit(pprof.StopCPUProfile)
|
||||
base.AtExit(func() {
|
||||
pprof.StopCPUProfile()
|
||||
if err = f.Close(); err != nil {
|
||||
base.Fatalf("error closing cpu profile: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
if base.Flag.MemProfile != "" {
|
||||
if base.Flag.MemProfileRate != 0 {
|
||||
|
|
@ -77,6 +82,9 @@ func startProfile() {
|
|||
if err := pprof.Lookup("heap").WriteTo(f, format); err != nil {
|
||||
base.Fatalf("%v", err)
|
||||
}
|
||||
if err = f.Close(); err != nil {
|
||||
base.Fatalf("error closing memory profile: %v", err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Not doing memory profiling; disable it entirely.
|
||||
|
|
@ -112,6 +120,11 @@ func startProfile() {
|
|||
if err := tracepkg.Start(f); err != nil {
|
||||
base.Fatalf("%v", err)
|
||||
}
|
||||
base.AtExit(tracepkg.Stop)
|
||||
base.AtExit(func() {
|
||||
tracepkg.Stop()
|
||||
if err = f.Close(); err != nil {
|
||||
base.Fatalf("error closing trace profile: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue