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: High CPU / memory leak when filtering model list window to empty results by d3vr · Pull Request #6435 · anomalyco/opencode

Conversation

@d3vr

@d3vr d3vr commented Dec 30, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Resolves #6433

When filtering the model selection list in the TUI to a point where no results match (resulting in an empty list), the application enters a CPU and memory spiral, causing 100% CPU usage and rapid memory consumption until the process crashes.

The Fix
Implemented a conditional rendering guard in packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx.

  • Change: Wrapped the <scrollbox> component in a <Show when={grouped().length > 0}> block.
  • Result: When the result list is empty, the ScrollBox component is completely unmounted from the render tree. This prevents the upstream ScrollBoxRenderable from ever encountering the hazardous 0-height state, effectively bypassing the infinite loop.

Verification

  • Confirmed that typing a filter that yields no results now displays "No results found" without spiking CPU/memory or crashing.
  • Confirmed that clearing the filter restores the list correctly.
2025-12-30-102356_1073x495_scrot

Sorry, something went wrong.

Uh oh!

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

joachim-isaksson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@d3vr
fix(cli): handle empty state in DialogSelect to prevent infinite layo…
90ff5e8
…ut loop
@d3vr

d3vr commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

Root Cause Analysis
The issue originates in the upstream @opentui/core library's ScrollBoxRenderable component:

  1. When the filtered list is empty, our DialogSelect component passes a height of 0 to the ScrollBox.
  2. Inside @opentui/core, the ScrollBoxRenderable listens to onSizeChange events to recalculate scrollbar properties.
  3. The recalculateBarProps method contains a workaround that unconditionally schedules a re-render on the next tick: process.nextTick(() => this.requestRender()).
  4. With a height of 0, the layout engine repeatedly fires onSizeChange (or oscillates), triggering an infinite recursive loop of Layout -> Size Change -> Schedule Render -> Layout.

(DISCLAIMER: I'm not sure this is actually the cause, I'm not too familiar with the opentui codebase, this is Gemini 3 Pro's analysis)

All reactions

Sorry, something went wrong.

Uh oh!

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

@d3vr d3vr changed the title Fix: Infinite Layout Loop in DialogSelect when Filtering to Empty Results Fix: High CPU / memory leak when filtering model list window to empty results Dec 30, 2025
@coleleavitt

coleleavitt commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

I can one up this I was getting scenarios of using 70GBs of ram but it might be a unrelated memory leak, would it even be feasible for developers to write opencode in Rust?

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Dec 30, 2025

Copy link
Copy Markdown
Member

/review

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

lgtm

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node
rekram1-node merged commit b378458 into anomalyco:dev Dec 30, 2025
hk9890 pushed a commit to hk9890/opencode that referenced this pull request Jan 1, 2026
@d3vr @hk9890
Fix: High CPU / memory leak when filtering model list window to empty…
1565370
… results (anomalyco#6435)
@LIHUA919 LIHUA919 mentioned this pull request Jan 18, 2026
Memory leak #9151
Closed
triklozoid pushed a commit to triklozoid/opencode that referenced this pull request Feb 2, 2026
@d3vr @triklozoid
Fix: High CPU / memory leak when filtering model list window to empty…
a3f03d2
… results (anomalyco#6435)
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
@d3vr
Fix: High CPU / memory leak when filtering model list window to empty…
34b391c
… results (anomalyco#6435)
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
@d3vr
Fix: High CPU / memory leak when filtering model list window to empty…
bbc6224
… results (anomalyco#6435)
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
@d3vr
Fix: High CPU / memory leak when filtering model list window to empty…
155d519
… results (anomalyco#6435)
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
@d3vr
Fix: High CPU / memory leak when filtering model list window to empty…
9a2e701
… results (#6435)
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
@d3vr
Fix: High CPU / memory leak when filtering model list window to empty…
2061faf
… results (anomalyco#6435)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

[BUG] Filtering the model list and resulting in an empty list causes a memory leak + high cpu spiral

Uh oh!

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

3 participants

@d3vr @coleleavitt @rekram1-node
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.