]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: note different between go test -memprofile and WriteHeapProfile
authorSean Liao <sean@liao.dev>
Fri, 12 Jul 2024 20:13:20 +0000 (21:13 +0100)
committerGopher Robot <gobot@golang.org>
Wed, 13 Nov 2024 19:02:55 +0000 (19:02 +0000)
Fixes #65328

Change-Id: I11242be93a95e117a6758ac037e143c3b38aa71c
Reviewed-on: https://go-review.googlesource.com/c/go/+/597980
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

src/runtime/pprof/pprof.go

index 4b7a9f63c6500608b0262e730ad6bf4a0facb3e3..b8458367f88a5beb9b3dd6215a7f3e57c02cfed0 100644 (file)
 //             }
 //             defer f.Close() // error handling omitted for example
 //             runtime.GC() // get up-to-date statistics
-//             if err := pprof.WriteHeapProfile(f); err != nil {
+//             // Lookup("allocs") creates a profile similar to go test -memprofile.
+//             // Alternatively, use Lookup("heap") for a profile
+//             // that has inuse_space as the default index.
+//             if err := pprof.Lookup("allocs").WriteTo(f, 0); err != nil {
 //                 log.Fatal("could not write memory profile: ", err)
 //             }
 //         }