Repository navigation
Closed
Closed
Copy link
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization
Description
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
Reacted by Francesca Pate-Rinaldi, konglong, j.yao.SUSE, Matt, Andrey Baksalyar, Dang Duy Toan, Louis Branch, Joe Harlow, cali (renato caliari), Vasiliy Kulikov and 5 more
Metadata
Metadata
Assignees
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization
Activity
github-actions commentedon Jan 21, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
Ruszero01 commentedon Jan 21, 2026
It seems that windows also has memory issues. The bun process will keep expanding until it fills up all the memory
JobyGitGud commentedon Feb 3, 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
Active Components at Time of Incident
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
Additional Context
2026-02-03T002133.log(31MB, created at 6:38 PM)Key Observations
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. 🤖💥
thdxr commentedon Apr 2, 2026
Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.