Memory leak during prolonged usage #3892

Closed
opened 2026-02-16 17:41:51 -05:00 by yindo · 5 comments
Owner

Originally created by @FurryWolfX on GitHub (Dec 26, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Image

Memory usage is increasing.

OpenCode version

1.0.203

Steps to reproduce

prolonged usage

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @FurryWolfX on GitHub (Dec 26, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description <img width="626" height="36" alt="Image" src="https://github.com/user-attachments/assets/ab7a0ec6-2d9c-4f51-a2a3-7acda11f3c4e" /> Memory usage is increasing. ### OpenCode version 1.0.203 ### Steps to reproduce prolonged usage ### Screenshot and/or share link _No response_ ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the windowsbugperf labels 2026-02-16 17:41:51 -05:00
yindo closed this issue 2026-02-16 17:41:51 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 26, 2025):

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

  • #6172: High CPU usage (100%+) during LLM streaming in long sessions due to O(n) text buffer rendering - includes detailed analysis of memory not being reclaimed
  • #5700: Too high memory usage
  • #4315: Memory stays unbounded: ACP session map + compacted tool outputs - identifies specific mechanisms causing memory leaks
  • #5363: opencode eating 70gb of memory - similar symptom of memory usage during prolonged sessions
  • #3013: Uses a huge amount of memory
  • #5220: Glob search uses 100% of CPU - related performance degradation

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 26, 2025): This issue might be a duplicate of existing issues. Please check: - #6172: High CPU usage (100%+) during LLM streaming in long sessions due to O(n) text buffer rendering - includes detailed analysis of memory not being reclaimed - #5700: Too high memory usage - #4315: Memory stays unbounded: ACP session map + compacted tool outputs - identifies specific mechanisms causing memory leaks - #5363: opencode eating 70gb of memory - similar symptom of memory usage during prolonged sessions - #3013: Uses a huge amount of memory - #5220: Glob search uses 100% of CPU - related performance degradation Feel free to ignore if none of these address your specific case.
Author
Owner

@rexbrahh commented on GitHub (Dec 30, 2025):

same here, opencode eats all my ram on macos if i leave it running for like 1 hour + and it just does not kill the memory unless i kill opencode

@rexbrahh commented on GitHub (Dec 30, 2025): same here, opencode eats all my ram on macos if i leave it running for like 1 hour + and it just does not kill the memory unless i kill opencode
Author
Owner

@rekram1-node commented on GitHub (Dec 30, 2025):

@rexbrahh just leaving it running? Doing nothing? What version of macos are u running then? I have never had that happen

@rekram1-node commented on GitHub (Dec 30, 2025): @rexbrahh just leaving it running? Doing nothing? What version of macos are u running then? I have never had that happen
Author
Owner

@rexbrahh commented on GitHub (Dec 30, 2025):

@rexbrahh just leaving it running? Doing nothing? What version of macos are u running then? I have never had that happen

no not idle, for complex prompts where it just works non-stop across several auto compactions which sometimes takes over an hour.

macos tahoe 26.3 beta 1 (always been on developer betas since 26), using opencode on ghostty tip release

Previously I was daily driving codex cli even had several of them working in parallel on git worktrees and it was fine.

I also posted this issue in oh-my-opencode repo which i'm using with opencode. but this issue was already happening before i started using oh-my-opencode.

Also what accompanies this memory issue with opencode and oh-my-opencode is severe input lags. very often it's 30 second + of input lag where the window just freezes -- no scrolling, no keyboard input, no mouse input, etc.

I suspect it's an issue with the bun runtime underneath.

@rexbrahh commented on GitHub (Dec 30, 2025): > [@rexbrahh](https://github.com/rexbrahh) just leaving it running? Doing nothing? What version of macos are u running then? I have never had that happen no not idle, for complex prompts where it just works non-stop across several auto compactions which sometimes takes over an hour. macos tahoe 26.3 beta 1 (always been on developer betas since 26), using opencode on ghostty tip release Previously I was daily driving codex cli even had several of them working in parallel on git worktrees and it was fine. I also posted this issue in oh-my-opencode repo which i'm using with opencode. but this issue was already happening before i started using oh-my-opencode. Also what accompanies this memory issue with opencode and oh-my-opencode is severe input lags. very often it's 30 second + of input lag where the window just freezes -- no scrolling, no keyboard input, no mouse input, etc. I suspect it's an issue with the bun runtime underneath.
Author
Owner

@navin1976 commented on GitHub (Jan 3, 2026):

Happening for me too over the last few days.
It gets up to near 10GB after an hour.

I set up another instance of opencode to look at what was happening on the next run and this was its output:

Root Cause Identified:

Metric Value
Process PID 33084 (OpenCode)
RAM Usage ~3.8 GB and fluctuating
Session "Reviewing orphaned entities audit status"
Scope 269,988 additions, 1,132 files
Messages 557 messages, growing
Parts stored 104,863 parts (~3.6 GB on disk)
State R+ (actively running)

The Problem:
The session is processing a massive code change (270K lines across 1K+ files). OpenCode stores all message history and diffs in memory, causing:

  1. Memory bloat - accumulating all conversation context
  2. Part storage explosion - 105K parts in the filesystem
  3. CPU churn - processing large file diffs repeatedly

Why it may hang:

  • Context window exhaustion (119K cached tokens visible in messages)
  • Memory pressure from holding 270K line diffs
  • Filesystem I/O bottleneck with 65K+ files in single directory
@navin1976 commented on GitHub (Jan 3, 2026): Happening for me too over the last few days. It gets up to near 10GB after an hour. I set up another instance of opencode to look at what was happening on the next run and this was its output: **Root Cause Identified:** | Metric | Value | |--------|-------| | Process | PID 33084 (OpenCode) | | RAM Usage | ~3.8 GB and fluctuating | | Session | "Reviewing orphaned entities audit status" | | Scope | 269,988 additions, 1,132 files | | Messages | 557 messages, growing | | Parts stored | 104,863 parts (~3.6 GB on disk) | | State | R+ (actively running) | **The Problem:** The session is processing a massive code change (270K lines across 1K+ files). OpenCode stores all message history and diffs in memory, causing: 1. Memory bloat - accumulating all conversation context 2. Part storage explosion - 105K parts in the filesystem 3. CPU churn - processing large file diffs repeatedly **Why it may hang:** - Context window exhaustion (119K cached tokens visible in messages) - Memory pressure from holding 270K line diffs - Filesystem I/O bottleneck with 65K+ files in single directory
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3892