Go has added Valgrind support
10 comments
·September 23, 2025defraudbah
looks very promising, one of the biggest issue in golang for me is profiling and constant memory leaks/pressure. Not sure if there is an alternative of what people use now
0x696C6961
How are you getting "constant memory leaks" in a GC'd language?
sim7c00
it's not hard. GC lets shit leak until it decided to clean it up...
do you think they will enable Valgrind if there's no leaks?
felixge
I'd love to hear more! What kind of profiling issues are you running into? I'm assuming the inuse memory profiles are sometimes not good enough to track down leaks since they only show the allocation stack traces? Have you tried goref [1]?. What kind of memory pressure issues are you dealing with?
[1] https://github.com/cloudwego/goref
Disclaimer: I work on continuous profiling for Datadog and contribute to the profiling features in the runtime.
pjmlp
Ideally, they would have learnt from other languages, and offered explicit control over what goes into the stack instead of relying into escape analysis alone.
As it is, the only way to currently handle that is with " -gcflags -m=3" or using something like VSCode Go plugin, via "ui.codelenses" and "ui.diagnostic.annotations" configurations.
Thaxll
pprof is pretty good, what do you need?
amelius
It only works if every package tests with it.
Otherwise the relevant warnings get swamped by a huge amount by irrelevant warnings.
This is why running Valgrind on Python code does not work.
0x696C6961
This is only useful for cgo correct?
pbd
Nothing says 'mature ecosystem' like finally getting debugging tools that C developers have had since the Clinton administration. Next up: maybe Go will discover gdb integration and we can debug like it's 1999.
> Instead of adding the Valgrind headers to the tree, and using cgo to call the various Valgrind client request macros, we just add an assembly function which emits the necessary instructions to trigger client requests.
Love that they have taken this route, this is the way bootstraped toolchains should be, minimal building blocks and everything else on the language itself.