Goroutine Leak Profiles
Go 1.27 adds a goroutineleak profile that finds goroutines permanently blocked on channels or sync primitives (Mutex, RWMutex, WaitGroup, Cond) in running programs, including production, with few or no false positives. It works by modifying the garbage collector's mark phase. Only unblocked goroutines start as roots, and blocked goroutines are added iteratively when a primitive blocking them is reachable from a live goroutine. Any goroutine never reached is reported as leaked. The profile is exposed via runtime/pprof and /debug/pprof/goroutineleak and is demonstrated on an unbuffered-channel early-return leak. Limitations: it cannot see IO or syscall blocking, it misses leaks where a primitive stays reachable through globals, and pathological "daisy-chain" cases serialize marking with O(n²) inspection. Periodic, infrequent profiling is the recommended way to keep overhead low.
Related posts
- Profiling improvements in Go 1.18
Datadog Engineering hardMasterGo 1.18's Linux CPU profiler no longer underestimates CPU bursts on multi-core systems. The fix replaces reliance on setitimer(2) with per-thread timer_create(2) timers, because process-directed SIGPROF signals don't queue, coalesce within 4 ms jiffy windows, and are unfairly distributed across threads. The release also fixes pprof labels that were missing or wrong: the profiler read gp instead of gp.m.curg during stack switches, mislabeled the first batch of samples through an off-by-one error, and let system goroutines inherit labels. A Go 1.17 compiler regression with inlined closures was also fixed; it made pc symbolization non-deterministic and produced negative counts in delta allocation profiles.
- Go Turns 17
The Go Blog easyNovice
Go's 17th anniversary recap covers Go 1.26 and 1.27. On the language side, it adds generic methods, self-referential constraints, `new` with an initial value, and nested struct literal keys. In the standard library, `encoding/json/v2` reached GA with up to 10× faster unmarshaling and now backs v1, and a GC-based goroutine leak profiler shipped. Performance work includes the Green Tea GC as default (10–40% less GC overhead), experimental SIMD packages, stack-allocated append backing stores and size-specialized allocation. The release also brings post-quantum TLS/HPKE/ML-DSA, a 7.5-hour urgent response to the eMudhra weak-key incident, and tooling built for humans and AI agents: `go fix` modernizers, `//go:fix inline`, gopls MCP and the pkg.go.dev API.
- Adding the V8 CPU Profiler to v8go
Shopify Engineering mediumAdeptExposing V8's CPU profiler through v8go, the Go library for running JavaScript in V8 isolates via Cgo, came down to a choice between lazily fetching each profile node property with its own Cgo call or eagerly building the whole call tree in C++ and rebuilding it in Go from a single pointer. Cgo calls cost roughly 54 ns Go-to-C and 149 ns C-to-Go, which made eager loading look like the obvious winner. Benchmarks showed lazy loading was actually faster on a small profile (~20µs vs ~25µs), and eager loading only pulled ahead on a large tree from the Hydrogen starter template (~60µs vs ~90µs). Keeping getters over private fields leaves room to offer both modes, and the broader lesson is to benchmark rather than trust intuition and to use inputs that reflect real usage.
- Debugging JavaScript Memory Leaks
Bun mediumAdept
Bun implements V8's writeHeapSnapshot API, so heap snapshots can be loaded and diffed in Chrome DevTools, where a steadily growing Delta column reveals leaks. bun:jsc's heapStats also reports per-type object counts, including objects protected from GC. Passing a Blob instead of a Uint8Array to repeated Response objects cut memory from ~1 GB to ~60 MB by avoiding per-Response copies. Common leak sources are closures retaining JSLexicalScope objects, active AbortSignals kept reachable by listeners (shown via JSC's isReachableFromOpaqueRoots), bound functions, and EventEmitter listeners that are never removed.
- How we tracked down a Go 1.24 memory regression across hundreds of pods
Datadog Engineering mediumAdeptUpgrading a data-processing service to Go 1.24 raised container memory by about 20% even though Go runtime metrics and heap profiles stayed flat. Comparing `/proc/[pid]/smaps` showed the Go heap's RSS had grown to nearly match its virtual size. Reproducing the workload with heapbench and running `git bisect` traced the cause to a `mallocgc` refactor. That refactor dropped an optimization that skipped re-zeroing fresh OS memory for large (>32 KiB) pointer-containing allocations, so untouched pages were committed to RAM. The fix ships in Go 1.25, and in the worst case RSS should roughly equal Go-reported virtual memory, which is useful when checking memory-limit headroom before rollout.