I Planted 10 Goroutine Leaks to Test Go 1.27's New Leak Detector

https://hackernoon.imgix.net/images/E971L7jSzcWVg1Ndja6mSyEUHTr1-8pd3a3n.webp

A worker blocks on a channel nobody reads, the handler that spawned it returns, and your process now carries a goroutine that will live until the next deploy. Nothing in your logs mentions it. Do that once per request, and you have a memory graph that climbs for days before anyone opens an issue.

Go 1.27, released on August 19, shipped a runtime-level answer: a new pprof profile called goroutineleak that asks the garbage collector to prove which goroutines can never run again. It existed behind GOEXPERIMENT=goroutineleakprofile in Go 1.26; in 1.27 the experiment flag is gone, and the profile is available by default, with an HTTP endpoint at /debug/pprof/goroutineleak. The runtime does the detection work each time you collect the profile, never on a background timer

Runtime leak detection with no third-party library and no test harness is a bold claim. I also have a personal stake: a few...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more