Skip to content

Memory leak during prolonged usage #6213

Closed as duplicate
Closed as duplicate

Description

@FurryWolfX

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

Activity

  1. added
    bug
    on Dec 26, 2025
  2. added
    perf
    on Dec 26, 2025
  3. github-actions commented on Dec 26, 2025

    @github-actions
    Contributor

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

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

  4. rexbrahh commented on Dec 30, 2025

    @rexbrahh

    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

  5. rekram1-node commented on Dec 31, 2025

    @rekram1-node
    Member

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

  6. rexbrahh commented on Dec 31, 2025

    @rexbrahh

    @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.

  7. navin1976 commented on Jan 3, 2026

    @navin1976

    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
  8. copilotenstar commented on Mar 22, 2026

    @copilotenstar

    Have to restart opencode once every 1-2 hours or so if prompting continously or my machine OOM's. I think opencode uses bun and bun has severe memory leak issues so likely related?

    oven-sh/bun#28427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugperfwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions