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/b6b7456b-16ad-4651-81f9-754184ad52c2n%40googlegroups.com.