From: Sean Liao Date: Fri, 12 Jul 2024 20:13:20 +0000 (+0100) Subject: runtime/pprof: note different between go test -memprofile and WriteHeapProfile X-Git-Tag: go1.24rc1~410 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d7ea9ff50b6c0386c7784b27f66083396fa404af;p=gostls13.git runtime/pprof: note different between go test -memprofile and WriteHeapProfile Fixes #65328 Change-Id: I11242be93a95e117a6758ac037e143c3b38aa71c Reviewed-on: https://go-review.googlesource.com/c/go/+/597980 LUCI-TryBot-Result: Go LUCI Reviewed-by: Carlos Amedee Reviewed-by: Cherry Mui Auto-Submit: Michael Pratt --- diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index 4b7a9f63c6..b8458367f8 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -44,7 +44,10 @@ // } // 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) // } // }