Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCode (Experimental Memory Leak Mitigation Fork)

DISCLAIMER: This fork contains experimental, AI-assisted modifications ("AI slop") created in an attempt to keep long-running sessions from crashing due to memory exhaustion.

  • Not a Complete Solution: This is not a proper architectural fix for the memory leak issues present in OpenCode. It addresses only approximately 20% of the observable leak surface by applying defensive bounds to queues and in-memory caches.
  • LLM Usage Acknowledgment: I am fully aware that project maintainers have explicitly requested contributors not to submit LLM-generated code or fixes. This repository exists strictly as a personal workaround to keep the tool operational on limited-resource machines, not as an official upstream recommendation or PR candidate.
  • Unresolved Root Causes: Deep runtime leaks—including EventTarget listener accumulation inside the bundled AI-SDK Effect runtime, Bun libuv conversion overhead, and V8 heap retention under heavy subagent workloads—are not fixed by these changes.

Applied Mitigations

  1. LSP Diagnostic and File Buffers (packages/opencode/src/lsp/client.ts)

    • Implemented a BoundedMap structure with LRU key eviction.
    • Restricted diagnostic state retention to MAX_DIAGNOSTICS_FILES = 5000.
    • Restricted open document text cache to MAX_OPEN_FILES = 1000.
  2. SSE Event Stream Buffer Bounding (packages/opencode/src/server/routes/instance/httpapi/handlers/event.ts)

    • Replaced unbounded event queue allocation (Queue.unbounded<EventV2.Payload>()) with a sliding buffer (Queue.sliding<EventV2.Payload>(1000)).
    • Drops stale progress events under severe backpressure to prevent workers from growing to 9+ GB RSS when clients disconnect or process events slowly (references upstream issue #31087).
  3. Instance State Cache Bounding (packages/opencode/src/effect/instance-state.ts)

    • Capped the per-directory active instance cache at capacity: 100 instead of Number.POSITIVE_INFINITY. Idle entries are evicted and re-instantiated on demand.
  4. TUI and Event Queue Clamping (packages/opencode/src/server/shared/tui-control.ts, packages/opencode/src/util/queue.ts)

    • Bounded internal AsyncQueue allocations to 1,000 items with shift-based eviction on overflow.

Upstream Project

For the official OpenCode repository, documentation, and installation instructions, visit: https://github.com/anomalyco/opencode

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages