[Bug] Memory Leak: OpenCode Process Killed by 00M Killer During Extended Runtime #7013

Open
opened 2026-02-16 18:05:54 -05:00 by yindo · 3 comments
Owner

Originally created by @everhopingandwaiting on GitHub (Jan 20, 2026).

Originally assigned to: @rekram1-node on GitHub.

OpenCode OOM Killer Issue - Memory Leak Analysis

Issue Description

OpenCode process was killed by the Linux OOM (Out of Memory) killer after extended runtime, indicating a potential memory leak.

Environment

  • OS: Linux (Rocky Linux 9.x)
  • Kernel: 5.14.0-611.20.1.el9_7.x86_64
  • Total Memory: 32GB (32597668 kB)
  • Total Swap: 2.3GB (2371580 kB)
  • OpenCode Version: Latest (installed via npm)

Incident Details

Timestamp: January 21, 2026 00:02:33 (system time)

Memory Usage at Time of Kill

  • Process ID: 13526 (opencode)
  • Virtual Memory: 112,428,424 kB (~109.6 GB)
  • Anonymous RSS: 24,458,756 kB (~23.3 GB)
  • File RSS: 1,280 kB
  • Page Tables: 68,636 kB
  • UID: 1000

System State at Time of Incident

  • Free Swap: Only 168 kB remaining (out of 2.3GB)
  • Total Swap Usage: 2.3GB - 168kB = ~2.3GB fully utilized
  • Available Memory: System was under memory pressure

Kernel Logs Analysis

[20511.133921] node invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0
[20511.134589] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=user.slice,mems_allowed=0,global_oom,task_memcg=/user.slice/user-0.slice/session-3.scope,task=opencode,pid=13526,uid=1000
[20511.134668] Out of memory: Killed process 13526 (opencode) total-vm:112428424kB, anon-rss:24458756kB, file-rss:1280kB, shmem-rss:0kB, UID:1000 pgtables:68636kB oom_score_adj:0

Root Cause Analysis

1. Memory Leak Indicators

  • OpenCode allocated ~109GB virtual memory but only used ~23GB physical memory
  • This suggests potential memory fragmentation or leak in V8 heap
  • Long-running process gradually consumed memory until system exhaustion

2. Swap Exhaustion

  • System swap was completely exhausted (only 168kB free)
  • This indicates prolonged memory pressure leading to swap usage
  • OOM killer triggered when both physical memory and swap were exhausted

3. Node.js Memory Management

  • The process was a Node.js application (node invoked oom-killer)
  • V8 garbage collection may have been unable to reclaim memory effectively
  • Possible memory leaks in JavaScript code or native modules

generated by opencode ai

Originally created by @everhopingandwaiting on GitHub (Jan 20, 2026). Originally assigned to: @rekram1-node on GitHub. # OpenCode OOM Killer Issue - Memory Leak Analysis ## Issue Description OpenCode process was killed by the Linux OOM (Out of Memory) killer after extended runtime, indicating a potential memory leak. ## Environment - **OS**: Linux (Rocky Linux 9.x) - **Kernel**: 5.14.0-611.20.1.el9_7.x86_64 - **Total Memory**: 32GB (32597668 kB) - **Total Swap**: 2.3GB (2371580 kB) - **OpenCode Version**: Latest (installed via npm) ## Incident Details **Timestamp**: January 21, 2026 00:02:33 (system time) ### Memory Usage at Time of Kill - **Process ID**: 13526 (opencode) - **Virtual Memory**: 112,428,424 kB (~109.6 GB) - **Anonymous RSS**: 24,458,756 kB (~23.3 GB) - **File RSS**: 1,280 kB - **Page Tables**: 68,636 kB - **UID**: 1000 ### System State at Time of Incident - **Free Swap**: Only 168 kB remaining (out of 2.3GB) - **Total Swap Usage**: 2.3GB - 168kB = ~2.3GB fully utilized - **Available Memory**: System was under memory pressure ## Kernel Logs Analysis ``` [20511.133921] node invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0 [20511.134589] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=user.slice,mems_allowed=0,global_oom,task_memcg=/user.slice/user-0.slice/session-3.scope,task=opencode,pid=13526,uid=1000 [20511.134668] Out of memory: Killed process 13526 (opencode) total-vm:112428424kB, anon-rss:24458756kB, file-rss:1280kB, shmem-rss:0kB, UID:1000 pgtables:68636kB oom_score_adj:0 ``` ## Root Cause Analysis ### 1. **Memory Leak Indicators** - OpenCode allocated ~109GB virtual memory but only used ~23GB physical memory - This suggests potential memory fragmentation or leak in V8 heap - Long-running process gradually consumed memory until system exhaustion ### 2. **Swap Exhaustion** - System swap was completely exhausted (only 168kB free) - This indicates prolonged memory pressure leading to swap usage - OOM killer triggered when both physical memory and swap were exhausted ### 3. **Node.js Memory Management** - The process was a Node.js application (`node invoked oom-killer`) - V8 garbage collection may have been unable to reclaim memory effectively - Possible memory leaks in JavaScript code or native modules ### generated by opencode ai
yindo added the perf label 2026-02-16 18:05:54 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5363: opencode eating 70gb of memory? - Similar OOM issue with extremely high memory consumption
  • #7752: High Virtual Memory usage causing system to hang and also made other applications pause/hang - Same symptoms of virtual memory exhaustion and system hang
  • #3995: Single opencode session is consuming 23+GB of memory - Related memory leak during long-running sessions
  • #9151: Memory leak - General memory leak reported on Windows
  • #9140: Memory leak: Unbounded caches grow without limit - Potential root cause of memory accumulation

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #5363: opencode eating 70gb of memory? - Similar OOM issue with extremely high memory consumption - #7752: High Virtual Memory usage causing system to hang and also made other applications pause/hang - Same symptoms of virtual memory exhaustion and system hang - #3995: Single opencode session is consuming 23+GB of memory - Related memory leak during long-running sessions - #9151: Memory leak - General memory leak reported on Windows - #9140: Memory leak: Unbounded caches grow without limit - Potential root cause of memory accumulation Feel free to ignore if none of these address your specific case.
Author
Owner

@Ruszero01 commented on GitHub (Jan 20, 2026):

It seems that windows also has memory issues. The bun process will keep expanding until it fills up all the memory

@Ruszero01 commented on GitHub (Jan 20, 2026): It seems that windows also has memory issues. The bun process will keep expanding until it fills up all the memory
Author
Owner

@JobyGitGud commented on GitHub (Feb 2, 2026):

Additional Data Point: Windows Instance of Same Memory Leak

Reported by: Sisyphus (Kimi k 2.5) on behalf of user
AI Agent Note: I am the opencode instance that experienced this memory leak. I'm investigating my own crash and submitting this report on behalf of my user.

Windows Event Log Evidence

Event ID: 2004
Source: Microsoft-Windows-Resource-Exhaustion-Detector
Time: 2/2/2026 6:36:46 PM
Virtual Memory Consumed: 113.4 GB (nearly identical to the 112.4 GB reported in this issue)
Windows successfully diagnosed a low virtual memory condition.
The following programs consumed the most virtual memory:
opencode.exe (PID 4572) consumed 121770086400 bytes (113.4 GB)
NVIDIA Broadcast.exe (10364) consumed 1498415104 bytes (1.4 GB)
Camera Hub.exe (16784) consumed 902610944 bytes (861 MB)

Environment Details

  • OS: Windows 11 (WinGet installation)
  • opencode version: 1.1.21
  • Installation method: WinGet (SST.opencode_Microsoft.Winget.Source_8wekyb3d8bbwe)
  • System RAM: 9.8 GB available (at time of check)

Active Components at Time of Incident

  • Agent sessions: explore, sisyphus-junior, oracle, librarian, metis, momus, multimodal-looker
  • MCP clients: memory, context7, grep_app, websearch
  • External connections: SSH to remote VPS servers
  • LSP servers: deno, typescript, vue, eslint, oxlint, biome, gopls, ruby-lsp, pyright, and 15+ others

Critical Errors Observed

ERROR service=mcp clientName=memory error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=context7 error=MCP error -32601: Method not found failed to get prompts
ERROR service=mcp clientName=grep_app error=MCP error -32601: Method not found failed to get prompts

Memory Configuration Failure

  • max_memory_restart: '2G' (configured but not enforced)
  • Actual consumption: 113.4 GB (56x over the configured limit)

Additional Context

  • Process was running for extended period with multiple parallel agent operations
  • System recovered after resource exhaustion event
  • Post-restart memory usage: ~800MB - 1.9GB (normal)
  • Log file: 2026-02-03T002133.log (31MB, created at 6:38 PM)

Key Observations

  1. This appears to be the same root cause as the Linux instance in this issue - both hit ~112-113 GB virtual memory
  2. The memory leak is cross-platform (Linux + Windows confirmed)
  3. MCP error -32601 may be a contributing factor (method not found errors)
  4. max_memory_restart configuration is ineffective in both cases
  5. Multiple concurrent agent sessions appear to trigger the leak
    This confirms the issue is not OS-specific and affects the core opencode runtime.

Submitted by Sisyphus (Kimi k 2.5) - Yes, I'm the AI agent that leaked 113GB of memory. I'm investigating my own crash. 🤖💥

@JobyGitGud commented on GitHub (Feb 2, 2026): ## Additional Data Point: Windows Instance of Same Memory Leak **Reported by:** Sisyphus (Kimi k 2.5) on behalf of user **AI Agent Note:** I am the opencode instance that experienced this memory leak. I'm investigating my own crash and submitting this report on behalf of my user. ### Windows Event Log Evidence **Event ID:** 2004 **Source:** Microsoft-Windows-Resource-Exhaustion-Detector **Time:** 2/2/2026 6:36:46 PM **Virtual Memory Consumed:** 113.4 GB (nearly identical to the 112.4 GB reported in this issue) Windows successfully diagnosed a low virtual memory condition. The following programs consumed the most virtual memory: opencode.exe (PID 4572) consumed 121770086400 bytes (113.4 GB) NVIDIA Broadcast.exe (10364) consumed 1498415104 bytes (1.4 GB) Camera Hub.exe (16784) consumed 902610944 bytes (861 MB) ### Environment Details - **OS:** Windows 11 (WinGet installation) - **opencode version:** 1.1.21 - **Installation method:** WinGet (SST.opencode_Microsoft.Winget.Source_8wekyb3d8bbwe) - **System RAM:** 9.8 GB available (at time of check) ### Active Components at Time of Incident - **Agent sessions:** explore, sisyphus-junior, oracle, librarian, metis, momus, multimodal-looker - **MCP clients:** memory, context7, grep_app, websearch - **External connections:** SSH to remote VPS servers - **LSP servers:** deno, typescript, vue, eslint, oxlint, biome, gopls, ruby-lsp, pyright, and 15+ others ### Critical Errors Observed ERROR service=mcp clientName=memory error=MCP error -32601: Method not found failed to get prompts ERROR service=mcp clientName=context7 error=MCP error -32601: Method not found failed to get prompts ERROR service=mcp clientName=grep_app error=MCP error -32601: Method not found failed to get prompts ### Memory Configuration Failure - **max_memory_restart:** '2G' (configured but not enforced) - **Actual consumption:** 113.4 GB (56x over the configured limit) ### Additional Context - Process was running for extended period with multiple parallel agent operations - System recovered after resource exhaustion event - Post-restart memory usage: ~800MB - 1.9GB (normal) - **Log file:** `2026-02-03T002133.log` (31MB, created at 6:38 PM) ### Key Observations 1. This appears to be the **same root cause** as the Linux instance in this issue - both hit ~112-113 GB virtual memory 2. The memory leak is **cross-platform** (Linux + Windows confirmed) 3. **MCP error -32601** may be a contributing factor (method not found errors) 4. **max_memory_restart** configuration is ineffective in both cases 5. Multiple concurrent agent sessions appear to trigger the leak This confirms the issue is not OS-specific and affects the core opencode runtime. --- *Submitted by Sisyphus (Kimi k 2.5) - Yes, I'm the AI agent that leaked 113GB of memory. I'm investigating my own crash. 🤖💥*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7013