Repository navigation
Opencode (1.2.24) leaks memory (until it's killed) #17237
Description
Description
I've been hitting a recurring issue where opencode seems to keep growing in memory until it eventually gets killed by the Linux OOM killer.
When that happens, the terminal window is often left in a broken state. Mouse movement and key presses start showing up as raw escape sequences, the pointer can feel trapped inside the window, and the only reliable way out is to force-close it.
At first I thought this was a Hyprland problem, but after looking through logs and tracking memory over time, it looks more like opencode is the thing going wrong first, and the terminal/input breakage happens afterwards.
Environment
- Lenovo laptop
- Arch Linux / Kernel:
6.18.13-arch1-1 - Hyprland
- Kitty terminal
- opencode 1.2.24 / no plugin
- node 22.20.0
- bun 1.3.10
What happens
The issue is not easy to trigger on demand. It tends to happen after opencode has been running for a while.
From what I could gather:
opencodekeeps increasing its memory usage over time- eventually the machine goes into memory pressure
- the kernel OOM killer selects
.opencode - after that, the terminal is sometimes left in a corrupted input state
I attached memory graphs instead of pasting a wall of numbers, but the overall pattern is a clear upward trend followed by process death.
Why I think opencode is the root cause
I originally suspected either Hyprland or terminal mouse/input handling, because the visible symptom is a terminal that looks half-frozen and keeps printing control sequences.
But the logs consistently point to .opencode being OOM-killed, and the broken terminal state seems to happen after that abrupt termination.
So my current understanding is:
opencodegrows in memory over time- the system hits heavy memory pressure
.opencodegets killed by the OOM killer- the terminal is left behind in a bad raw/input state
That makes the issue look compositor-related from the outside, but the trigger seems to be inside opencode.
Expected behavior
opencodeshould not keep growing in memory during normal use- even if it crashes or gets terminated, it should not leave the terminal in a broken state
Actual behavior
- memory usage keeps increasing over time
- the process eventually gets killed by OOM
- the terminal may become unusable afterwards and require force-closing
Activity
github-actions commentedon Mar 12, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct or adds new information not covered by the above, feel free to keep it open and note what differentiates it.
[-]Opencode leaks memory (until it's killed)[/-][+]Opencode (1.2.24) leaks memory (until it's killed)[/+]binarydoubling commentedon Mar 13, 2026
Yep... yeah this is a major major major issue right now. I'm really sorry. I enjoyed using OpenCode and unfortunately cannot until this gets resolved... there's probably a LOT of places where memory is leaking, and it's ultimately up to the maintainers to triage everything, since they know the codebase best.
jnorthrup commentedon Mar 21, 2026
🚨 URGENT: Cross-Project Memory Leak Crisis - Hardware Damage Risk
We investigated memory leaks across WebKit-based runtimes (Bun, Claude Code, OpenCode) and found a critical pattern affecting all embedders.
Hardware Risk Statement
On Apple Silicon Macs:
On Linux servers:
Our Investigation Findings
Bun Runtime (WebKit JSC):
JSC::SlotVisitor::drainFromSharedrace condition (7,214 frames)WTF::HashTable::removeIterator(7,214 frames)WTF::Vector<>::operator=(7,220 frames)JSC::ASTBuilder::createForOfLoop(713 frames)OpenCode (from your issues):
Common Root Cause
WebKit JavaScriptCore parallel GC marking phase:
SlotVisitor::drainFromSharedUpstream References
Tool We Built
We created
test/asan_tracker.zig(760 lines) that:Happy to share this tool with OpenCode maintainers.
Urgency: Auto-Close Bot Pattern
We observed issues #17837 and #17185 were closed by github-actions bot within 2 hours for "contributing guidelines" - despite containing:
This pattern is dangerous for memory safety issues:
Recommended Actions
Immediate:
perfandbuglabelsShort-term:
Long-term:
Cross-Project Coordination
We're coordinating with:
Memory leaks don't respect project boundaries - this is an ecosystem-wide crisis.
Evidence:
Please prioritize this over formatting requirements.
jnorthrup commentedon Mar 21, 2026
🚨 URGENT: Cross-Project Memory Leak Crisis - Hardware Damage Risk
We investigated memory leaks across WebKit-based runtimes (Bun, Claude Code, OpenCode) and found a critical pattern affecting all embedders.
Hardware Risk Statement
On Apple Silicon Macs:
On Linux servers:
Our Investigation Findings
Bun Runtime (WebKit JSC):
JSC::SlotVisitor::drainFromSharedrace condition (7,214 frames)WTF::HashTable::removeIterator(7,214 frames)WTF::Vector<>::operator=(7,220 frames)JSC::ASTBuilder::createForOfLoop(713 frames)OpenCode (from your issues):
Common Root Cause
WebKit JavaScriptCore parallel GC marking phase:
SlotVisitor::drainFromSharedUpstream References
Tool We Built
We created an ASAN tracker (760 lines of Zig) that:
Happy to share this tool with OpenCode maintainers.
Urgency: Auto-Close Bot Pattern
We observed issues #17837 and #17185 were closed by github-actions bot within 2 hours for "contributing guidelines" - despite containing:
This pattern is dangerous for memory safety issues:
Recommended Actions
Immediate:
perfandbuglabelsShort-term:
Long-term:
Cross-Project Coordination
We're coordinating with:
Memory leaks don't respect project boundaries - this is an ecosystem-wide crisis.
Evidence:
Please prioritize this over formatting requirements.
thdxr commentedon Apr 2, 2026
Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.