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?
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