Goroutine Leak Profiles
3 days ago
- Go 1.27 introduces a new goroutine leak profiler that precisely detects goroutines permanently blocked on channels or sync primitives, with minimal false positives.
- The profiler works by leveraging the garbage collector to trace live goroutines and identify those that are unreachable, marking them as leaked.
- Examples include common patterns like early return causing senders to block, double sends, timeouts, missing close on channels, and mutual blocking between channels and locks.
- Limitations include inability to detect leaks from non-standard blocking (e.g., I/O), memory reachability through globals, and non-deterministic timing issues.
- Performance overhead is manageable but can be significant in pathological cases (e.g., daisy-chain dependencies), mitigated by periodic profiling.