Memory usage grows very quickly when running commands with large output #6985

Open
opened 2026-02-16 18:05:49 -05:00 by yindo · 2 comments
Owner

Originally created by @kov on GitHub (Jan 20, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Simplest way to reproduce this is to run !find / and watch memory usage of the opencode processs. This happens both with the bash tool and with the interactive command. The memory usage grows at a much larger rate than you would expect from the command output.

The problem, I believe, is that we are constantly allocating strings, bigger and bigger ones, when we accumulate the output with string concatenation. That happens so quickly that the GC has little opportunity to catch up, leading to the very quick growth.

I bet it's one of the main issues people keep being bitten by when they see large memory usage issues, but I found no report specifically about the bash tool / interactive command buffer, so I am creating this one to associate with the pull request.

Plugins

No response

OpenCode version

git

Steps to reproduce

  1. open opencode
  2. !find /
  3. watch memory usage over time

Screenshot and/or share link

Running !find /. I've seen it go all the way to almost 70% in some cases. I saw the OOM killer working overtime yesterday because of this. Had to add a new swap file just to get it through the task I was working on.

Image

Operating System

Fedora 43

Terminal

Gnome Terminal and macOS terminal over ssh.

Originally created by @kov on GitHub (Jan 20, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Simplest way to reproduce this is to run !find / and watch memory usage of the opencode processs. This happens both with the bash tool and with the interactive command. The memory usage grows at a much larger rate than you would expect from the command output. The problem, I believe, is that we are constantly allocating strings, bigger and bigger ones, when we accumulate the output with string concatenation. That happens so quickly that the GC has little opportunity to catch up, leading to the very quick growth. I bet it's one of the main issues people keep being bitten by when they see large memory usage issues, but I found no report specifically about the bash tool / interactive command buffer, so I am creating this one to associate with the pull request. ### Plugins _No response_ ### OpenCode version git ### Steps to reproduce 1. open opencode 2. !find / 3. watch memory usage over time ### Screenshot and/or share link Running !find /. I've seen it go all the way to almost 70% in some cases. I saw the OOM killer working overtime yesterday because of this. Had to add a new swap file just to get it through the task I was working on. <img width="865" height="225" alt="Image" src="https://github.com/user-attachments/assets/ff2930ce-07a6-45a8-8b4b-28c59e4198dd" /> ### Operating System Fedora 43 ### Terminal Gnome Terminal and macOS terminal over ssh.
yindo added the bugperf labels 2026-02-16 18:05:49 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7893: Severe scroll lag in VSCode/Cursor integrated terminal on WSL2 after large output
  • #4239: TUI hangs when shell outputs massive log
  • #7450: [FEATURE]: Truncate output of long scripts/diffs by default
  • #6310: Sessions become unusable due to large LSP diagnostics
  • #6119: [Bug] TUI fails to render with raw ANSI output and critical memory leak on startup
  • #5363: opencode eating 70gb of memory?
  • #3995: Single opencode session is consuming 23+GB of memory

These issues all report memory-related problems with large outputs. Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #7893: Severe scroll lag in VSCode/Cursor integrated terminal on WSL2 after large output - #4239: TUI hangs when shell outputs massive log - #7450: [FEATURE]: Truncate output of long scripts/diffs by default - #6310: Sessions become unusable due to large LSP diagnostics - #6119: [Bug] TUI fails to render with raw ANSI output and critical memory leak on startup - #5363: opencode eating 70gb of memory? - #3995: Single opencode session is consuming 23+GB of memory These issues all report memory-related problems with large outputs. Feel free to ignore if none of these address your specific case.
Author
Owner

@mohamedbouddi7777-dev commented on GitHub (Feb 1, 2026):

Free the world

@mohamedbouddi7777-dev commented on GitHub (Feb 1, 2026): Free the world
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6985