You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does OpenCode suffer from memory leaks? A single window is consuming over 20 GB of memory. #20626
I had three windows open in OpenCode on my 64GB M5 Pro, and the fan was whirring loudly. I suspected that a specific application was consuming an excessive amount of memory. Initially, I thought it might be Chrome; closing it did free up a small amount of memory, so I proceeded to close my other applications one by one. Finally, I closed just one of the OpenCode windows and discovered that it immediately released 20GB of memory. Why would it consume such a massive amount of memory?
I am using version 1.3.2 and am still encountering this issue.
Plugins
oh-my-opencode
OpenCode version
1.3.2
Steps to reproduce
When I leave the window open and running continuously—specifically, after keeping it open for several hours—I notice that the memory usage becomes extremely high.
This looks like a real long-running memory growth issue rather than a single one-off allocation.
The most likely root causes are:
Unbounded SSE/event buffering for long-lived windows
The app keeps long-lived event streams open.
If a client/window becomes slow or disconnect cleanup does not happen promptly, queued events can keep accumulating in memory.
This is especially bad for high-frequency events (message deltas, tool updates, etc.), and is much more likely to produce multi-GB growth than heartbeats alone.
Shell/tool output retained in memory
Large stdout/stderr from bash/tool execution was being accumulated in memory instead of being capped/spilled early.
In a long-running session, a few large commands or repeated tool usage can compound badly.
Session prompt subprocess output also had the same accumulation pattern
There was a second output-retention path in prompt/session execution, so the problem was not limited to one tool path.
Why this matches the symptom: if one OpenCode window owns those queues/buffers, closing that single window would immediately release a very large amount of memory, which is exactly what was reported here.
So the short version is: likely a combination of unbounded event queue growth + unbounded shell output retention over time.
Activity
github-actions commentedon Apr 2, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct from the above, please add context explaining how it differs.
silent-night-no-trace commentedon Apr 2, 2026
I am using version 1.3.2 and am still encountering this issue. How can I resolve it?
max-flizpay commentedon Apr 2, 2026
Lets just rewrite OpenCode in Rust?
jwcrystal commentedon Apr 2, 2026
This looks like a real long-running memory growth issue rather than a single one-off allocation.
The most likely root causes are:
Unbounded SSE/event buffering for long-lived windows
Shell/tool output retained in memory
Session prompt subprocess output also had the same accumulation pattern
Why this matches the symptom: if one OpenCode window owns those queues/buffers, closing that single window would immediately release a very large amount of memory, which is exactly what was reported here.
So the short version is: likely a combination of unbounded event queue growth + unbounded shell output retention over time.
thdxr commentedon Apr 2, 2026
Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.