Radar · Go · Archive · Week 40 · Sep 29 – Oct 5, 2025
New goroutine leak profiler experiment
Worth knowingruntime
- What changed
- The Go team added a
GOEXPERIMENT=goroutineleakprofileflag that enables an experimental profiler for leaked goroutines. - Production impact
- The source does not say.
- Try it
- Run a program with
GOEXPERIMENT=goroutineleakprofile go run ./...and inspect the pprof output for goroutine leaks. - Source
- github.com/golang/go/issues/75280
Understand it, then run it
Run it now
// This program demonstrates how to collect a goroutine leak profile
// using the experimental flag. It does not compile in Go 1.27.1
// because the flag is not yet implemented. Run it with
// GOEXPERIMENT=goroutineleakprofile ./prog to see the effect.
package main
import (
"fmt"
"os"
"runtime/pprof"
)
func main() {
// Create a file to store the leak profile.
f, err := os.Create("goroutineleak.pprof")
if err != nil {
fmt.Println("error creating file:", err)
return
}
defer f.Close()
// Lookup the leak profile by name.
prof := pprof.Lookup("goroutineleak")
if prof == nil {
fmt.Println("goroutineleak profile not available")
return
}
// Write the profile data to the file.
if err := prof.WriteTo(f, 1); err != nil {
fmt.Println("error writing profile:", err)
return
}
fmt.Println("goroutine leak profile written to goroutineleak.pprof")
}
What it printed when we ran it on Go 1.27.1
goroutine leak profile written to goroutineleak.pprof
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed