aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof/pprof.go
diff options
context:
space:
mode:
authorRoland Illig <roland.illig@gmx.de>2018-08-13 21:28:28 +0200
committerBrad Fitzpatrick <bradfitz@golang.org>2018-08-22 19:47:12 +0000
commitf2d7e66e98d64941313147c0dfe2f31645830716 (patch)
treed160323eb9cb2144fc31c23662066b513d91be59 /src/runtime/pprof/pprof.go
parent3879ea54ed1f5c266657ffe593e2a8e1b63401ec (diff)
downloadgo-f2d7e66e98d64941313147c0dfe2f31645830716.tar.xz
runtime/pprof: fix resource leak in documentation
Fixes #26970 Change-Id: I0f2695434a53550cf84f702e9d8d02a37448d396 Reviewed-on: https://go-review.googlesource.com/129195 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/pprof/pprof.go')
-rw-r--r--src/runtime/pprof/pprof.go3
1 files changed, 2 insertions, 1 deletions
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()
// }
// }
//