Skip to content

SSH & remote-server PTY tabs excluded from hidden-view parking causes unbounded renderer heap growth #8652

Closed

Description

@iridite

Summary

The hidden-view parking system (terminalHiddenViewParking) is designed to free renderer memory by unmounting hidden terminal panes after 30 seconds. However, SSH PTYs and remote-server (remote:) PTYs are explicitly excluded from parking eligibility. For users whose entire workflow runs through SSH or a remote server (e.g. connecting to remote Windows or Linux machines), this means zero tabs ever get parked, and every hidden terminal retains its full xterm.js instance — including the complete scrollback buffer — in the renderer heap indefinitely.

Scope: This issue is specifically about SSH and remote-server terminal workflows — not local PTYs (which already support park/unpark via daemon snapshot replay).

Impact

Each unparked SSH/remote terminal holds roughly 10–20 MB in the renderer heap (5,000-row scrollback at ~2.6 KB/row of cell data, plus xterm rendering overhead). With 5–10 SSH or remote-server terminals open across multiple worktrees:

Hidden SSH / remote terminals Estimated renderer heap
3 ~40–60 MB
5 ~70–100 MB
10 ~150–200 MB

This matches traces from production logs showing renderer heap growing from 23 MB (baseline) to 100–257 MB peak in sessions with zero unhandled rejections and zero other errors. The growth is triggered by agent runs producing large terminal output that fills the scrollback buffer, and is never reclaimed because the xterm instance is never parked.

Reproduction

  1. Configure ORCA to connect to a remote machine (Windows or Linux) via SSH or remote-server for all repos.
  2. Open 5+ terminal tabs across multiple worktrees. Run agents or commands that produce substantial output in each.
  3. Switch away from those tabs for > 30 seconds.
  4. Open Chrome DevTools → Memory → Take heap snapshot.
  5. Observe: xterm.js BufferLine / Buffer objects dominate the heap; retained heap remains at 100+ MB regardless of tab switching, and does not decrease over time.

Root cause

terminal-hidden-view-parking.ts excludes remote: PTYs and SSH PTYs from parking eligibility. The feature therefore provides no memory benefit to SSH-only and remote-server workflows — the most memory-intensive use cases.

Why SSH & remote-server PTYs are harder to park

I understand the exclusion likely exists because:

  1. Parking unmounts the xterm instance, destroying the in-memory scrollback.
  2. For local PTYs, the daemon snapshot/replay capability reconstructs history on re-hydrate.
  3. SSH relays and remote-server PTYs may not have equivalent snapshot support, making lossless park/unpark difficult.

Suggested mitigations (in order of implementation complexity)

Option A — Reduce scrollback depth for hidden SSH / remote tabs (low effort)

When an SSH or remote-server terminal tab transitions to "hidden beyond cold-park threshold," reduce xterm's active scrollback from the user's configured rows (e.g. 5,000) to a minimal value (e.g. 100–200 rows). The full buffer is already gone after re-hydration anyway once parking is fully supported; reducing it while hidden bounds the worst-case cost without requiring full park/unpark mechanics.

Option B — Compact in-memory snapshot for hidden SSH / remote tabs (medium effort)

When hiding an SSH or remote-server tab past the cold-park delay, serialize the scrollback to a compact format (e.g. plain-text lines stripped of ANSI color codes, or a binary cell dump) and release the xterm instance. Re-hydrate from the compact snapshot on reveal. Color fidelity is lost, but the tab remains functional and the memory cost drops by ~10×.

Option C — Extend daemon snapshot replay to SSH & remote-server PTYs (higher effort)

If the SSH relay / remote-server path (daemon side) can be extended to buffer the same PTY output snapshots that local PTYs already provide, those tabs become eligible for full park/unpark on the same path as local tabs.

Workaround

Users with SSH- or remote-server-heavy workflows can reduce terminalScrollbackRows (Settings → Terminal → Scrollback) from the default 5,000 to 1,000. This reduces per-terminal memory by ~80% and is currently the only available mitigation.

Environment

  • Platform: macOS (Apple Silicon)
  • ORCA: v1.4.135
  • Connection: SSH / remote server (Windows machines; all repos via SSH or remote)
  • Observed renderer heap peak: 257 MB (baseline 23 MB)
  • All terminal tabs are SSH or remote-server PTYs — parking provides zero memory benefit

Related

Activity

  1. Zaradacht commented on Jul 15, 2026

    @Zaradacht

    Additional field evidence: this also affects Orca remote-runtime PTYs, not only direct SSH PTYs.

    Environment:

    • Orca 1.4.141 on macOS
    • 23 unique saved PTY references: 15 remote: and 8 local
    • 7 remote runtime hosts, each retaining roughly 15–22 saved sessions
    • hidden-view parking enabled via its default setting

    Observed over a 23-hour renderer lifetime:

    • renderer CPU: sustained roughly 85–103%
    • renderer RSS: roughly 3.2 GB
    • renderer_memory breadcrumbs: used JS heap grew from 215 MB to 1,545 MB over 11.9 hours
    • after restarting Orca: renderer RSS returned to roughly 313 MB and CPU returned to low idle usage

    The breadcrumbs contained no corresponding renderer unhandled rejections or remote-runtime errors, and there were no browser webviews retained. Git polling frequency was also too low to account for the sustained CPU.

    The code path supports the same root cause described here: isSnapshotBackedTerminalPty rejects both remote: runtime PTYs and SSH PTYs, so 15 of the 23 PTYs in this workspace could never enter hidden-view parking and retained their xterm renderer state indefinitely.

    PR #7448 appears to be the comprehensive fix: it adds bounded terminal pane eviction and includes a remote-runtime park/restore path. Linking this field report so the issue and implementation are connected.

  2. iridite commented on Jul 16, 2026

    @iridite
    ContributorAuthor

    Confirming @Zaradacht's analysis, and adding field data from the SSH side after running v1.4.143 (which includes the rejection-fix from PR #8279).

    Environment

    • macOS Orca → Windows via SSH exclusively
    • 5–8 SSH terminal tabs open across multiple repos (all ssh:<id>@@pty-<n> IDs)
    • terminalHiddenViewParking: true, terminalScrollbackRows: 1000 (reduced from 5000 mid-observation)

    What PR #8279 changed

    Unhandled rejections dropped to zero and the crash rate fell significantly. But heap growth continued at the same rate — because the rejection accumulation was a side-effect leak, not the primary one.

    Today's data (v1.4.143, 0 rejections all day)

    09:21  120min   23 → 69 MB   (+46 MB)
    11:22   30min   23 → 104 MB  (+81 MB)
    11:53   62min   23 → 82 MB   (+59 MB)
    12:55   71min   23 → 93 MB   (+70 MB)
    14:35  143min   23 → 215 MB  (+192 MB)  ← peak today
    17:59   31min   23 → 82 MB   (+59 MB)
    

    Average growth rate: ~70 MB/hr. Zero rejections throughout.

    Why this is the SSH PTY parking exclusion

    The 14:35 session: 5 SSH tabs open, all with 1000-row scrollback. Tab switches happened throughout but the hidden tabs never got their buffers trimmed because isSnapshotBackedTerminalPty() returns false for all of them. The xterm instance for each hidden SSH pane stayed fully allocated the entire time.

    Supporting PR #7448

    PR #7448 (terminal pane eviction, opt-in, marked READY since Jul 7) is the comprehensive fix. Its design correctly covers both SSH PTYs and remote-runtime PTYs — it evicts the entire pane DOM + xterm instance on a timer and replays from the main-process mirror on reveal, rather than trying to trim inside the live xterm.

    My PR #8655 (scrollback trim only) is a narrower stopgap with lower risk — but PR #7448 eliminates the problem structurally. Would strongly support enabling the experimental flag in a near-term build so users with long-lived SSH or remote-runtime workflows can opt in.

  3. added
    bug
    on Jul 27, 2026
  4. changed the title [-]SSH PTY tabs excluded from hidden-view parking causes unbounded renderer heap growth for SSH-heavy workflows[/-] [+]SSH & remote-server PTY tabs excluded from hidden-view parking causes unbounded renderer heap growth[/+] on Jul 28, 2026
  5. AmethystLiang commented on Jul 28, 2026

    @AmethystLiang
    Contributor

    Related issues / tracking map

    Keeping a single place for the remaining remote/SSH renderer RAM growth path.

    Issue Relationship
    #6288 (closed) Earlier remote server CPU + memory report. CPU fixed in #6667; one memory path (preload IPC listener leak) fixed in #6564. That report also saw renderer heap pinned at the V8 limit (~3.5 GB) with remote runtime timeouts — symptoms overlap, but the parking exclusion here is a separate remaining root cause.
    #10928 (open) Generic high RAM/CPU during normal usage (no remote/SSH detail yet). Likely overlapping for multi-terminal users; not a confirmed duplicate until we know whether their tabs are local vs SSH/remote:.
    #8260 Renderer crash / white screen with heap pressure; related symptom class.

    Why not fully merge #6288 into this one

    #6288 already shipped two real fixes (relay ps scan thrash + preload subscription leak). Closing this issue as “already fixed by #6288” would hide the still-open structural gap: SSH and remote: PTYs never enter hidden-view parking, so long-lived remote workflows keep full xterm instances forever.

    Fix PRs still relevant here

    If maintainers prefer a single open tracker for remote/SSH renderer RAM, keep this issue (#8652) as the canonical one and fold new field reports here.

  6. added
    orca-remote-server
    on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugorca-remote-server

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions