]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: close memory profile
authorguoguangwu <guoguangwug@gmail.com>
Tue, 26 Mar 2024 06:38:55 +0000 (06:38 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 26 Mar 2024 19:53:53 +0000 (19:53 +0000)
Change-Id: If17e982dd0272e90972d2d4a94b1a744343ae2ec
GitHub-Last-Rev: c8d03566b3e66a6de58e778102fa60f5d46ab2d9
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>

src/cmd/link/internal/ld/main.go

index 13077668e7be5a07678b152399efb3b8a62143d5..5a4d7f9451b505d78daeb0151ac79464d13829b6 100644 (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)
+                       }
                })
        }
 }