From: Roland Illig Date: Mon, 13 Aug 2018 19:28:28 +0000 (+0200) Subject: runtime/pprof: fix resource leak in documentation X-Git-Tag: go1.12beta1~1326 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f2d7e66e98d64941313147c0dfe2f31645830716;p=gostls13.git runtime/pprof: fix resource leak in documentation Fixes #26970 Change-Id: I0f2695434a53550cf84f702e9d8d02a37448d396 Reviewed-on: https://go-review.googlesource.com/129195 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index c1024c99ed..74cdd15cfb 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -28,6 +28,7 @@ // if err != nil { // log.Fatal("could not create CPU profile: ", err) // } +// defer f.Close() // if err := pprof.StartCPUProfile(f); err != nil { // log.Fatal("could not start CPU profile: ", err) // } @@ -41,11 +42,11 @@ // if err != nil { // log.Fatal("could not create memory profile: ", err) // } +// defer f.Close() // runtime.GC() // get up-to-date statistics // if err := pprof.WriteHeapProfile(f); err != nil { // log.Fatal("could not write memory profile: ", err) // } -// f.Close() // } // } //