# fatal error: runtime: out of memory (timer channel leak)

- **ID:** `go/goroutine-timer-channel-leak`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Creating many time.Timer or time.Ticker without stopping them, causing goroutine and channel leaks that exhaust memory.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Always stop timers after use with defer.** (95% success)
   ```
   timer := time.NewTimer(1 * time.Second)
defer timer.Stop()
select {
case <-timer.C:
    // do something
}
   ```
2. **Use time.NewTicker and stop it when done.** (90% success)
   ```
   ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
for range ticker.C {
    // periodic work
    if condition {
        break
    }
}
   ```

## Dead Ends

- **Using time.After in a loop without resetting.** — Each call to time.After creates a new timer; if not stopped, they accumulate. (90% fail)
- **Assuming timers are garbage collected after firing.** — Timers are not GC'd until they fire or are stopped; if not stopped, they remain in memory. (80% fail)
