Skip to content

memory leak #7046

Closed
Closed

Description

@zx06

Description

Image

Plugins

oh-my-opencode

OpenCode version

1.1.3

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

windows11

Terminal

windows terminal

Activity

  1. added
    bugSomething isn't working
    on Jan 6, 2026
  2. added
    perfIndicates a performance issue or need for optimization
    on Jan 6, 2026
  3. github-actions commented on Jan 6, 2026

    @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. hffmnnj commented on Jan 6, 2026

    @hffmnnj

    +1

  5. wzx140 commented on Jan 7, 2026

    @wzx140

    +1

  6. kfuglsang commented on Jan 7, 2026

    @kfuglsang

    Can confirm the memory leak is quite bad on Windows. Typically have to kill OpenCode every 30 minutes (on a 32gb machine).

    Just had a long-running prompt (i18n extraction in a codebase) that only did file reads and file writes for a period of time. This alone was clearly leaking as the Bun process raised from initially ~500mb memory to ~1,3gb in a few minutes, and still climbing.

  7. DuckForgeDev commented on Jan 8, 2026

    @DuckForgeDev

    I'm using OpenCode on Windows 11 with PowerShell 7. After launching OpenCode, even if I don't initiate any conversation, the memory usage keeps increasing until it completely cripples my system. From Task Manager, I can see that numerous PowerShell processes are being spawned continuously, and new ones keep launching nonstop. I don't understand what's causing this issue.

    Image
  8. ShuraWW commented on Jan 27, 2026

    @ShuraWW

    +1

    Image
  9. HexaField commented on Feb 1, 2026

    @HexaField

    i'm trying to build on the opencode sdk and with just a few tests in a test suite my system quickly runs out of memory

  10. reachcreator commented on Feb 2, 2026

    @reachcreator

    Yeah this issue has definitely returned. Just managed to close it down before it crashed my 32gig box with just one OpenCode open and not doing anything else...

  11. kryptobaseddev commented on Feb 22, 2026

    @kryptobaseddev

    This is still reproducing as of the latest dev branch. I traced four specific leak sources from this issue and fixed them in #14650:

    1. Tool output survives compaction — compaction.ts prune() sets time.compacted on tool parts but never clears state.output or state.attachments. The strings stay in both the DB and the in-memory store. toModelMessages already substitutes "[Old tool result content cleared]" for compacted parts, so the data was being kept for nothing. Fix: clear output/attachments when compacting.

    2. LSP diagnostics map grows without bound — The diagnostics Map in lsp/client.ts and the files tracking object accumulate entries for every file ever touched. Added FIFO eviction caps (2,000 diagnostics, 1,000 open files).

    3. Pending permissions leak on session delete — Session.remove() didn't clear pending permission entries for the deleted session. Added PermissionNext.clearSession() that rejects and removes them.

    4. TUI event listener accumulation — 8 sdk.event.on() calls across app.tsx, session/index.tsx, and prompt/index.tsx never saved their unsubscribe functions. Each component remount added duplicates. Fixed with onCleanup() handlers.

    The tool output issue (1) compounds with the delta accumulation problem — together they're what causes the 30+ GB growth @reachcreator and @HexaField are seeing in extended sessions. The PR caps delta strings at 1 MB per part field and adds a 10 MB SSE buffer guard as well.

    Tested with a 2.5-hour session including heavy tool use and subagent tasks. RSS held steady at ~2,500 MB instead of climbing unbounded.

  12. aniel300 commented on Feb 22, 2026

    @aniel300

    I am still seeing high ram usage 😭🤦‍♂️

  13. thdxr commented on Apr 2, 2026

    @thdxr
    Member

    Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperfIndicates a performance issue or need for optimizationwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions