Jochen Voss, On linux/amd64
xxx.go: https://go.dev/play/p/Wq_OU49LVQZ $ go build xxx.go && ./xxx $ go tool pprof xxx mem.prof File: xxx Type: inuse_space Time: Mar 1, 2023 at 11:03pm (EST) No samples were found with the default sample value type. Try "sample_index" command to analyze different sample values. Entering interactive mode (type "help" for commands, "o" for options) (pprof) quit $ go tool pprof -alloc_space xxx mem.prof File: xxx Type: alloc_space Time: Mar 1, 2023 at 11:03pm (EST) Entering interactive mode (type "help" for commands, "o" for options) (pprof) top Showing nodes accounting for 6919.54MB, 98.93% of 6994.32MB total Dropped 77 nodes (cum <= 34.97MB) Showing top 10 nodes out of 18 flat flat% sum% cum cum% 3564.91MB 50.97% 50.97% 3564.91MB 50.97% golang.org/x/exp/slices.Insert[...] (inline) 3073.64MB 43.94% 94.91% 3073.64MB 43.94% seehuhn.de/go/layout.(*Skip).Minus 123.51MB 1.77% 96.68% 123.51MB 1.77% seehuhn.de/go/layout.(*Skip).Clone (inline) 104.50MB 1.49% 98.17% 6866.56MB 98.17% seehuhn.de/go/layout.(*knuthPlassLineBreaker).Run 48.48MB 0.69% 98.87% 60.68MB 0.87% compress/flate.NewWriter 4.50MB 0.064% 98.93% 6878.06MB 98.34% seehuhn.de/go/layout.(*Engine).EndParagraph 0 0% 98.93% 60.68MB 0.87% compress/flate.NewWriterDict 0 0% 98.93% 60.68MB 0.87% compress/zlib.(*Writer).Write 0 0% 98.93% 60.68MB 0.87% compress/zlib.(*Writer).writeHeader 0 0% 98.93% 56.12MB 0.8% fmt.Fprintln (pprof) quit $ Peter On Wednesday, March 1, 2023 at 8:55:30 AM UTC-5 Jochen Voss wrote: > Dear all, > > I'm trying to profile memory use of a program, following the instructions > at https://go.dev/blog/pprof , but I can't get memory profiling to work. > Am I doing things wrong, or is this broken? > > Simplified code is at https://go.dev/play/p/Wq_OU49LVQZ . (The code > doesn't run on the playground, but you can download it and run it locally.) > > Following the advice from https://pkg.go.dev/runtime/pprof I added the > following code to the end of my main() function: > > f, err := os.Create("mem.prof") > if err != nil { > log.Fatal("could not create memory profile: ", err) > } > runtime.GC() // get up-to-date statistics > if err := pprof.WriteHeapProfile(f); err != nil { > log.Fatal("could not write memory profile: ", err) > } > err = f.Close() > if err != nil { > log.Fatal(err) > } > > When I run the code, this gives me a "mem.prof" file (5084 bytes). But > when I start "go tool pprof" on this file, I get > > >>> go tool pprof xxx mem.prof > File: xxx > Type: inuse_space > Time: Mar 1, 2023 at 1:15pm (GMT) > No samples were found with the default sample value type. > Try "sample_index" command to analyze different sample values. > Entering interactive mode (type "help" for commands, "o" for options) > (pprof) top10 > Showing nodes accounting for 0, 0% of 0 total > flat flat% sum% cum cum% > > There seem to be no samples in this file. > > What am I doing wrong? > > All the best, > Jochen > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c5e8ef6d-fad1-417a-8619-b271688dc7a8n%40googlegroups.com.