Skip to content

Massive memory usage. #1649

Backlog
Backlog

Description

@HumanMus1c
image

Activity

  1. HumanMus1c commented on Nov 29, 2026

    @HumanMus1c
    Author
  2. Hona commented on Nov 29, 2026

    @Hona
    Member

    Thanks for the screenshot and debug archive! I inspected opencode-debug-20261129T060911.zip, and it looks like that zip was exported from the Electron OpenCode app (2.4.2, Electron 44.9.1) rather than OpenCode (Rune), so it doesn't contain Rune's build version, logs, or memory breakdown.

    Because the OpenCode (Rune) (9) row in Task Manager is collapsed, we also can't yet tell which of those 9 processes is holding the ~2,050 MB — for example:

    • the main opencode-desktop.exe (Rune UI / caches / GPU),
    • the embedded opencode-browser-engine.exe (CEF browser/GPU/renderer child processes),
    • the local opencode CLI server sidecar, or
    • open terminal / plugin child processes.

    If you still see this on the latest build (several memory fixes landed recently, including bounded image caches and background session unloading in #1352, browser-tab hibernation in #1393, and Rune image/GPU memory fixes in #1494, #1630, and #1650), could you share:

    1. A screenshot with OpenCode (Rune) expanded (>) in Task Manager so we can see which child process(es) hold the memory.
    2. In OpenCode (Rune), open the Command Palette and run Capture heap snapshots, then paste just the small memory.json from the generated opencode-heap-* folder in Downloads. (Please do not attach the *.heapsnapshot file publicly — only memory.json, which contains MiB totals by allocator tag and server memory.)
    3. Your OpenCode (Rune) version/build (from Settings → About) and roughly what was open (number of tabs, whether the browser pane or terminals were open).

    Keeping this open until we have a breakdown from OpenCode (Rune) so we can fix the exact culprit rather than guessing.

  3. HumanMus1c commented on Nov 29, 2026

    @HumanMus1c
    Author

    The option "Export Logs..." on OpenCode (Rune) did not respond after being clicked.

  4. Hona commented on Nov 29, 2026

    @Hona
    Member

    Thanks for flagging that — we tracked down why Export Logs… didn't respond on Windows and fixed it in #1679 (824b522b):

    • On Windows, the app's performance diagnostics hold a mandatory exclusive lock on Logs\perf\.perf.lock while running, which caused Export Logs… to abort the entire zip export with a lock violation and silently drop the error (with no toast or File Explorer window).
    • Export Logs… now skips .lock files and handles any locked/unreadable file without aborting the archive, honors Windows's Downloads known folder, reveals the archive via Windows Shell (SHOpenFolderAndSelectItems, fixing paths with spaces too), and shows clear Exporting logs… / Logs exported (with a Reveal in File Explorer button) / error toasts.

    (Verified locally via Windows cargo check, cargo clippy, and guardrails; not yet run live in a desktop GUI window or on macOS/Linux.)

    Leaving this issue open — once you try the next dev build, feel free to share the Export Logs… archive and/or the expanded Task Manager screenshot + memory.json from Capture heap snapshots so we can pinpoint the memory usage.

  5. HumanMus1c commented on Nov 29, 2026

    @HumanMus1c
    Author

    Ok, Thanks for fixing. I exported the logs.

    opencode-debug-20261129T131651.zip

  6. Hona commented on Nov 29, 2026

    @Hona
    Member

    Thanks for sharing the Rune debug archive! Here is what we found from analyzing perf.json and perf.log on 0.0.0-dev-508:

    1. Fixed: Idle timer echo chamber & UI-thread allocation storm (#1692, 1a17c842)

    • perf.log showed a steady 45–60 Hz idle poll storm whenever the app sat idle or minimized, churning ~1.3–1.5 MB/s while minimized (~38.8–44.5 MB every 30 s; ~6.6 GB over ~86 min) and ~3.8–5.1 MB/s while visible and resting (~7.5 GB over ~57 min), plus unnecessary 30 s redraws.
    • Root cause: automations::source::poll called tx.wake_after(30s) unconditionally on every poll, so every frame/poll from 30 s of activity echoed 30 s later in a permanent self-sustaining loop (with other periodic poll timers — memory sweep, inbox age tick, server health, and browser RPC — also re-arming wakes on every poll).
    • Fix landed in perf(desktop): stop 30s wake_after echo chamber and idle poll churn #1692: Each of those periodic pollers now tracks an explicit armed-wake state so each deadline is scheduled once (and zero timers are armed when no automations are active/supported), unchanged background automation polls no longer force redraws, and idle polls skip redundant Tracked writes and allocations.
    • (Verified locally on Windows via pwsh scripts/guardrails.ps1 (10/10), cargo check, and cargo clippy; not yet verified live in a desktop GUI window or on macOS/Linux.)

    2. Why we are keeping #1649 open for verification

    • On Windows, perf.json currently reports capabilities.process_memory: false (resident_bytes: null, footprint_bytes: null) because process memory counters are currently macOS-only, and Export Logs… does not capture a per-process memory breakdown.
    • That means perf.log confirmed the UI-thread allocation/wake storm above, but could not yet confirm which process(es) inside the OpenCode (Rune) (9) group held the ~2 GB Task Manager total (for example opencode-desktop.exe, embedded opencode-browser-engine.exe CEF subprocesses, or the local opencode CLI server sidecar and any installed plugins/watchers).

    Once you try the next dev build containing #1692, please let us know if memory usage is still high — and if it is, an expanded OpenCode (Rune) Task Manager screenshot or just the small memory.json from Command Palette → Capture heap snapshots will tell us immediately which process to target next.

  7. elliotsecops commented on Nov 30, 2026

    @elliotsecops

    Cross-platform idle check for #1649 (not a reproduction of the Windows ~2 GiB report):

    • Build: 0.0.0-dev-510 Linux x64 AppImage from the official dev release service. Downloaded size was 221,653,496 bytes; SHA-256 matched the published metadata (e2b713ba0199e57a3d0545cfb51917bfb605ef7fbc607ff8cf1463c756e10a7a).
    • Host: Ubuntu 26.04.1, kernel 7.0.0-44-generic, Wayland, Intel UHD Graphics 620.
    • Setup: Bubblewrap-isolated profile with no sessions, installed plugins, open terminals, or browser tabs. The browser engine was downloaded/warmed but not launched. Left idle for about 176 seconds after startup.
    • Memory: Sum of the test processes' RSS peaked at 680,912 KiB during startup and was 480,548 KiB at the end. At that point, the bundled opencode-cli was 337,032 KiB RSS and the Rune UI process was 126,412 KiB RSS. Summed RSS includes shared pages and is not a unique-memory total.
    • Idle activity: perf.log had six records across the run. After startup, the last two logged frames were around 167.7–168.8 seconds (seq 53 and 55); there was no sustained high-frequency frame stream in this minimal idle run. Linux reports resident_bytes and footprint_bytes as null, so process RSS was read from /proc.

    Result: no continuing growth toward 2 GiB was observed in this minimal Linux idle smoke test. It does not reproduce the reporter's Windows setup or its nine-process group, and it does not validate memory with active sessions, browser pages, plugins, or terminals. The original report still needs verification in that environment.

  8. HumanMus1c commented on Dec 1, 2026

    @HumanMus1c
    Author
  9. Hona commented on Dec 1, 2026

    @Hona
    Member

    Thanks for sharing the expanded Task Manager screenshot and the 0.0.0-dev-517 debug archive — that pinpointed the exact cause immediately.

    1. Breakdown from the screenshot & logs (0.0.0-dev-517)

    • Idle poll storm (perf(desktop): stop 30s wake_after echo chamber and idle poll churn #1692) is fixed: perf.log shows no sustained idle frame storm (only 6 startup/interaction frame anomalies across the ~4.5 min run), and the app sits at 0% CPU / 0% GPU.
    • Per-process memory inside OpenCode (Rune) (9) (1,857.6 MB total):
      • OpenCode (Rune) (Rust/Rune UI process): 58.3 MB (3.1%)
      • Bun (local opencode serve --service CLI sidecar): 422.9 MB (22.8%)
      • 7 × Node.js (7 separate instances of a configured stdio MCP server, ~176–202 MB each): 1,376.5 MB (74.1%)

    2. Root cause & fix shipped in #2025 (c59f2b3f)

    • server-1/opencode.log showed that on every launch, opencode-desktop eagerly attached 6 rune client MCP WebSockets within ~1.7 seconds — one for every project listed in the sidebar (used_projects()), including a Windows case-only duplicate of the same folder.
    • Opening a client MCP WebSocket for a directory forces the local OpenCode server to boot a full project location instance (plugins, file watchers, and all configured stdio MCP servers). Together with the server's default home location, that booted 7 project locations at startup and spawned 7 separate ~200 MB Node.js MCP processes (~1.38 GB) plus extra state in the Bun sidecar, even for unopened projects.
    • Fix landed in perf(rune-mcp): attach client MCP only to active/open folders, not all sidebar projects #2025 (c59f2b3f):
      1. rune_mcp now attaches only to folders that actually have an open tab, active session, or active draft on the active server (removing the eager used_projects() loop; unopened sessions were already rejected by rune_mcp's router).
      2. Windows folder paths are deduplicated case- and separator-insensitively before attaching so differing letter casing never boots duplicate server locations for the same folder.
      3. Tab folder attachment and routing are scoped strictly to tabs belonging to the active server.

    (Verified locally on Windows via pwsh scripts/guardrails.ps1 (11/11), cargo check, and cargo clippy --no-deps; not yet run live in a desktop GUI window or on macOS/Linux.)

    Leaving this issue open so you can retest on the next dev build containing #2025 — you should see far fewer Node.js MCP child processes at launch (only for folders you actually open, plus the server's default location if global MCP servers are configured).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions