0Pricing
Go Academy · Lesson

Leak Detection and Cancellation

Ensuring goroutines exit and preventing leaks

What is a goroutine leak?

A goroutine leak occurs when a goroutine starts but never terminates. Leaked goroutines accumulate over time, consuming stack memory and CPU until the process is killed.

Common leak: blocked channel receive

A goroutine waiting on a channel receive that never gets a value blocks forever:

go func() {
    v := <-ch // leaks if no sender and ch is never closed
    use(v)
}()

All lessons in this course

  1. Pipeline and Stage Patterns
  2. errgroup for Concurrent Error Handling
  3. Semaphore Pattern
  4. Leak Detection and Cancellation
← Back to Go Academy