{
  "id": "go/goroutine-not-scheduled",
  "signature": "fatal error: runtime: out of memory",
  "signature_zh": "致命错误: 运行时: 内存不足",
  "regex": "fatal\\ error:\\ runtime:\\ out\\ of\\ memory",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Creating an excessive number of goroutines without limit, exhausting system memory.",
  "root_cause_type": "generic",
  "root_cause_zh": "无限创建 goroutine，导致系统内存耗尽。",
  "versions": [
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Temporary fix; doesn't solve the underlying goroutine leak.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "WaitGroup doesn't limit concurrency; it only waits for all to finish.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use a worker pool pattern: \n\nconst maxWorkers = 10\njobs := make(chan int)\nvar wg sync.WaitGroup\nfor i := 0; i < maxWorkers; i++ {\n    wg.Add(1)\n    go func() {\n        defer wg.Done()\n        for j := range jobs {\n            process(j)\n        }\n    }()\n}\n// send jobs and close",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use semaphore channel to limit goroutine count: \n\nsem := make(chan struct{}, 10)\nfor _, task := range tasks {\n    sem <- struct{}{}\n    go func(t task) {\n        defer func() { <-sem }()\n        process(t)\n    }(task)\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}