# fatal error: out of memory allocating heap arena metadata

- **ID:** `go/goroutine-count-explosion`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Unbounded go statement per incoming request or per item spawns millions of goroutines, exhausting memory.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.19 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   sem := make(chan struct{}, 100)
for _, item := range items {
    sem <- struct{}{}
    go func(it Item) {
        defer func() { <-sem }()
        process(it)
    }(item)
}
   ```
2. **** (93% success)
   ```
   jobs := make(chan Job, 1000)
for i := 0; i < runtime.NumCPU(); i++ {
    go func() {
        for j := range jobs { process(j) }
    }()
}
   ```

## Dead Ends

- **** — Goroutine stacks dominate memory; GC tuning does not reduce goroutine count. (85% fail)
- **** — GOMEMLIMIT forces GC but goroutines keep spawning; OOM still occurs or throughput collapses. (70% fail)
