Hi all,
I'm not sure that hprof still works. There was some work started in #16410 to update it or create a new heap dump viewer, but to my knowledge that did not complete.
golang.org/x/debug/cmd/viewcore is another option. I think the version at master also does not work with recent Go versions, but the nice folks at Cockroach Labs have sent some patches to get it to work with more recent releases. In theory, it should work with Go 1.16 and 1.17 with those patches, though I have had more success with Go 1.16.
FWIW, I think viewcore is an underutilized tool, and it would be nice to get it into shape, though of course there are many balls in the air.
Here is a from scratch example of installing & using viewcore to check:
* where memory is being used in a test program, and
* an example of checking why a particular object is reachable.
# install go1.16
go install golang.org/dl/go1.16.15@latest
go1.16.15 download
# build viewcore with cockroachdb pull request
git clone https://github.com/golang/debug
cd debug
git fetch origin pull/7/head:pull-7
git checkout pull-7
go1.16.15 install ./cmd/viewcore
cd ..
# build & run a test program that allocates
# a configurable amount of heap
export GOTRACEBACK=crash
go1.16.15 install -gcflags='all=-N -l' github.com/thepudds/arena-performance/cmd/binarytree-original@latest
binarytree-original 24 & # will run for ~20 sec, using ~2.3 GB RSS
# create a core
kill -SEGV $! # pid of binarytree-original background process
ls -l ./core
# view it with viewcore
viewcore ./core
# explore the core
(viewcore) histogram --top 5
count size bytes type
60279514 16 964472224 unk16
8 10240 81920 runtime.p
45 384 17280 runtime.g
9 1024 9216 runtime.m
1 8192 8192 [34+5?]bucket<string,*unicode.RangeTable>
(viewcore) reachable c00031d580
main.Run.func1
main.NewTree
main.NewTree.unk →
c06dea4710 unk16 f0 → f0
c0425c8d40 unk16 f0 → f0
c01426eb70 unk16 f0 → f0
c00a0aac60 unk16 f0 → f0
c0058748a0 unk16 f8 → f0
That was on Debian 11 (bullseye).
Regards,
--thepudds