| TUI event listeners |
sdk.event.on() in app.tsx, session route, prompt — never unsubscribed |
Listeners accumulate on every navigation/re-render |
#16695, #8254, #9147 |
| Unbounded Maps/Sets |
LSP diagnostics, Bus subscriptions, RPC listeners — grow without eviction |
Monotonic memory growth over session lifetime |
#16695, #12259 |
| Timer/interval leaks |
Models refresh interval, leader timeout, state disposal timeout — never cleared |
Closures + captured state retained indefinitely |
#16695, #9148 |
| Session data retention |
Sync store never frees previous session's messages/parts/diffs on switch |
Memory scales with number of sessions visited |
#16695, #10392 |
| Plugin subscriber stacking |
Bus.subscribeAll() called without storing unsubscribe handle |
Each init() stacks another permanent wildcard subscriber |
#16346 |
| Message array retention |
Full msgs array stays alive during processor.process() |
Large arrays pinned in memory unnecessarily |
#16346 |
| Subagent deallocation |
Subagent sessions never deallocated after task completion |
GB-scale growth in long-running sessions |
#14650, #15435 |
| Event-reducer accumulation |
Message delta strings accumulate without cap |
Unbounded string growth |
#14650 |
| SSE stream leaks |
SSE connections not properly cleaned up on disconnect |
Stale connections hold memory |
#15646, #9146 |
| Process/Bus cleanup |
Child processes and Bus subscriptions not cleaned on instance disposal |
Resources retained after they're needed |
#15646, #13186, #9149 |
| Subscription disposal |
No dispose functions for Bus subscriptions |
Permanent listeners on long-lived instances |
#7914, #7032 |
| Tool output retention |
Tool output and attachments not cleared when pruning |
Dead data accumulates |
#7049 |
| OAuth transport leaks |
MCP OAuth transports accumulate without timeout |
Abandoned flows hold memory |
#9145 |
| LSP stderr buffering |
LSP server stderr not consumed, grows unbounded |
Memory growth per LSP server |
#16241 |
| Zombie processes |
Missing cleanup handlers leave child processes running |
Process accumulation over time |
#13186, #15757 |
| MCP server accumulation |
Idle MCP server instances never disposed |
Process count grows indefinitely |
#15326 |
| Instance disposal |
No idle-timeout disposal in serve mode |
Instances live forever |
#16616 |
Description
During extended usage, OpenCode exhibits unbounded memory growth from multiple independent sources. This has been independently reported and investigated by 20+ contributors, resulting in a massive wave of PRs that collectively address the full scope of the problem.
Scope of Memory Leaks
In-Memory Leaks (Runtime)
sdk.event.on()in app.tsx, session route, prompt — never unsubscribedBus.subscribeAll()called without storing unsubscribe handlemsgsarray stays alive duringprocessor.process()Database & Storage Leaks
Real-World Impact
All Related PRs
Over 20 open PRs addressing memory leaks, spanning January–March 2026:
Core memory leak fixes
Targeted fixes
Monitoring & diagnostics
Related Issues
serveandwebcommands leak child processes on exit; SSE heartbeat interval leaks on server-initiated close #14091, PTY handle leaks #15592 — Various memory growth reports