GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: consolidate memory leak fixes from #14650 and #8953 by tda1017 · Pull Request #15435 · anomalyco/opencode

Conversation

@tda1017

@tda1017 tda1017 commented Feb 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #9385
Relates to #7046, #9151

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR consolidates memory leak fixes from two existing PRs that have been open for a while:

  • fix: resolve memory leak issues across multiple subsystems #14650 by @kryptobaseddev
  • feat(bash): stream large output to tmpfile with filtering and GC #8953 by @cgwalters

All credit goes to the original authors. I'm submitting this to help move these fixes forward.

Key fixes included:

  1. Subagent session deallocation (tool/task.ts) — Calls Session.remove() after task completion. Previously subagent sessions were never cleaned up, causing GB-scale memory growth.

  2. Delta string cap (event-reducer.ts) — Caps accumulated part field strings at 1MB with FIFO eviction.

  3. Bash output streaming (tool/bash.ts) — Streams command output to tmpfile when >50KB, preventing O(n²) memory growth for large outputs.

  4. SSE buffer guard (serverSentEvents.gen.ts) — 10MB limit prevents unbounded growth during stalled streams.

  5. MCP OAuth transport TTL (mcp/index.ts) — 5-minute auto-eviction for stale OAuth entries.

  6. TUI event listener cleanup (app.tsx, session/index.tsx, prompt/index.tsx) — Properly unsubscribes 8 event listeners on component unmount.

  7. LSP diagnostics cap (lsp/client.ts) — 2,000-file cap with FIFO eviction.

  8. Additional — AsyncQueue termination, bus cleanup, PTY chunking, shutdown disposal.

How did you verify your code works?

Built locally and ran extended sessions. The original PRs (#14650, #8953) contain detailed testing methodology — @kryptobaseddev ran 2.5 hour stress tests showing RSS stabilized at ~2.5GB vs previous 25GB+ growth.

Screenshots / recordings

N/A - backend memory fixes, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Co-authored-by: Keaton Hoskins [email protected]
Co-authored-by: Colin Walters [email protected]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

syunaht, Piping, and zzzzz1111139 reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
kryptobaseddev and others added 3 commits February 28, 2026 15:14
@kryptobaseddev root
fix: resolve 10 memory leak sources across multiple subsystems
6efcd20
Fixes subagent session deallocation, delta string cap, tool output on compact,
SSE buffer guard, MCP OAuth transport TTL, pending permissions cleanup,
TUI event listener cleanup, LSP diagnostics cap, and AbortSignal listener.

Original work from PR anomalyco#14650 by @kryptobaseddev
Co-authored-by: Keaton Hoskins <[email protected]>
@cgwalters root
fix: stream large bash output to tmpfile to prevent O(n²) memory growth
2e0f232
Stream command output directly to a temp file when it exceeds threshold,
avoiding memory bloat for commands with huge output. Adds output_filter
param for regex-based line filtering.

Original work from PR anomalyco#8953 by @cgwalters
Co-authored-by: Colin Walters <[email protected]>
root @kryptobaseddev
@cgwalters root
fix: port AsyncQueue termination, bus cleanup, PTY chunking, and shut…
ff830d9
…down disposal

Additional memory leak fixes for queue termination, event bus cleanup,
PTY output chunking, and proper shutdown disposal.

Co-authored-by: Keaton Hoskins <[email protected]>
Co-authored-by: Colin Walters <[email protected]>
@tda1017
tda1017 requested a review from adamdotdevin as a code owner February 28, 2026 07:16
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 28, 2026
This was referenced Feb 28, 2026
fix: resolve memory leak issues across multiple subsystems #14650
Closed
feat(bash): stream large output to tmpfile with filtering and GC #8953
Closed
@github-actions

github-actions Bot commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PRs Found

The current PR (#15435) is a consolidation of two existing PRs that address specific memory leak issues:

Primary Sources (being consolidated):

  • fix: resolve memory leak issues across multiple subsystems #14650: "fix: resolve memory leak issues across multiple subsystems" - by @kryptobaseddev (10 memory leak sources)
  • feat(bash): stream large output to tmpfile with filtering and GC #8953: "feat(bash): stream large output to tmpfile with filtering and GC" - by @cgwalters (bash output streaming)

Related Memory Leak Fixes (addressing similar issues):

  • fix(web): dispose idle MCP server instances to prevent process accumulation #15326: "fix(web): dispose idle MCP server instances to prevent process accumulation"
  • fix: clear tool output and attachments when pruning to prevent memory leak #7049: "fix: clear tool output and attachments when pruning to prevent memory leak"
  • fix: add LRU eviction to LSP client file and diagnostics tracking #7050: "fix: add LRU eviction to LSP client file and diagnostics tracking"
  • fix: clean up pending permissions when session is deleted #7154: "fix: clean up pending permissions when session is deleted"
  • fix(core): add dispose functions to prevent subscription memory leaks #7032: "fix(core): add dispose functions to prevent subscription memory leaks"
  • fix: resolve multiple memory leaks causing unbounded RAM growth ( Now passing: && Fixed failing tests for windows ) #13514: "fix: resolve multiple memory leaks causing unbounded RAM growth"

These related PRs address similar memory management concerns across different subsystems (MCP servers, LSP diagnostics, permissions cleanup, subscriptions). While #15435 is specifically consolidating #14650 and #8953, the other PRs represent parallel memory leak fix efforts that may warrant review for consistency or potential interaction effects.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 28, 2026
@github-actions

github-actions Bot commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Feb 28, 2026
fix(tui): recover event stream after lock/sleep disconnect #15436
Closed
3 of 6 tasks
root added 2 commits February 28, 2026 16:01
root root
fix: skip Unix-specific bash tests on Windows
763998b
root root
fix: make output_filter small-output test shell-safe on Windows
ab406e5
@github-actions github-actions Bot mentioned this pull request Mar 2, 2026
fix: prevent memory leaks from SSE streams, LSP, Bus, and process cleanup #15646
Closed
3 of 6 tasks
nexxeln
nexxeln suggested changes Mar 2, 2026
View reviewed changes

@nexxeln nexxeln left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task_id resumability is currently broken: we delete subagent sessions immediately after completion (Session.remove(session.id)), but the tool contract/output still say the same task_id resumes the session. Could we preserve resumability instead of deleting the session right away?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nexxeln

nexxeln commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

could you also please fix the merge conflicts

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tda1017 added 2 commits March 5, 2026 14:30
tda1017
fix: preserve task_id resumability by not removing subagent session i…
697d2b5
…mmediately
tda1017
Merge upstream/dev and resolve conflicts
6493c15
@tda1017

tda1017 commented Mar 5, 2026

Copy link
Copy Markdown
Author

@nexxeln Merge conflicts resolved! The branch is now up to date with upstream/dev. Please take another look when you have a chance. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@binarydoubling binarydoubling mentioned this pull request Mar 9, 2026
Multiple memory leaks cause unbounded RAM growth during extended TUI usage #16697
Closed
@Piping

Piping commented Mar 13, 2026

Copy link
Copy Markdown

really need this feature and previous work merged into tools!! current opencode eats all memory of my machine!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Apr 7, 2026
fix: bash tool memory leak #21321
Closed
3 tasks done
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin
1 more reviewer
@nexxeln nexxeln nexxeln requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Memory leak

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@tda1017 @nexxeln @Piping @kryptobaseddev @cgwalters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.