cmd/link: close memory profile

Change-Id: If17e982dd0272e90972d2d4a94b1a744343ae2ec
GitHub-Last-Rev: c8d03566b3
GitHub-Pull-Request: golang/go#66531
Reviewed-on: https://go-review.googlesource.com/c/go/+/574335
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Than McIntosh <thanm@google.com>
This commit is contained in:
guoguangwu 2024-03-26 06:38:55 +00:00 committed by Gopher Robot
parent 51a96f86f7
commit 8bf9f4bb66

View file

@ -519,6 +519,10 @@ func startProfile() {
if err := pprof.Lookup("heap").WriteTo(f, writeLegacyFormat); err != nil {
log.Fatalf("%v", err)
}
// Close the file after writing the profile.
if err := f.Close(); err != nil {
log.Fatalf("could not close %v: %v", *memprofile, err)
}
})
}
}