Skip to content

bb host process grew to 77GB RSS and froze the machine; orphaned dev processes in deleted managed worktrees compound the leak #1660

Open

Description

@mattwyckhouse

Incident report from a heavy multi-thread orchestration workload (macOS, Apple Silicon).

What happened

The main bb host process grew to ~77GB RSS over a day of heavy use and froze the machine; the user had to kill and restart bb. All in-flight agent turns died with it (recovered afterward via bb thread fork --workspace reuse).

Compounding factor found during recovery

88 orphaned development processes (dev servers, watchers, test runners spawned by agent threads) whose cwd pointed into deleted managed worktrees had accumulated over the program's history. bb's environment lifecycle reclaimed the worktrees but nothing reaped the processes started from them; they kept running from deleted inodes indefinitely. This class recurs: we have twice previously traced machine-wide memory/CPU exhaustion to this pattern (orphaned dev stacks ~1GB each, plus browser tabs reconnecting to dead backends).

Requests

  1. Investigate unbounded host RSS growth under sustained multi-thread load (many threads created/archived per day, large tool outputs). A heap/RSS ceiling with graceful degradation, or periodic compaction, would prevent the machine freeze.
  2. When bb's environment lifecycle prunes a managed worktree, reap (or at least surface) processes whose cwd resolves into the pruned path. Even an opt-in bb doctor --reap-orphans would help.
  3. Expose host memory telemetry (e.g. bb status --resources) so orchestration-level watchdogs can alert before the machine locks up.

Workarounds in place on our side: a 10-minute automation that reaps deleted-worktree orphans and alerts on any process RSS > 8GB / bb-family total > 16GB (alert-only for bb itself).

Activity

  1. added theissue type on Aug 17, 2026
  2. added
    host
    workspaces
    on Aug 18, 2026
  3. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1660.html

    • Verdict: PARTIALLY REPRODUCED · root-cause confidence: medium
    • Root cause (short): Environment teardown (RuntimeManager.destroyEnvironment -> runtime.shutdown() on the direct bridge child, then removeWorktree rm -rf) never enumerates or signals processes rooted in the worktree; agent-started background processes survive with a (deleted) cwd — and, since Claude Code runs its Bash tool in a new session (detached:true), they are not even in the bridge's process group, so only a cwd scan can find them. The 77GB RSS growth itself is unreproduced (no RSS ceiling/telemetry; daemon event-sink queue deliberately unbounded).
    • Proposed fix: (1, covers the reproduced case) In RuntimeManager.destroyEnvironment, before workspace.destroy(), scan for processes whose cwd is inside the worktree (/proc/*/cwd on Linux, lsof -d cwd / proc_pidinfo on macOS), SIGTERM->SIGKILL them, return the reaped list in the environment.destroy result (bump HOST_DAEMON_PROTOCOL_VERSION) and record a thread event; also run the same scan periodically for processes with a (deleted) cwd under the managed worktrees root. (2, defence in depth, does NOT reach the reproduced orphan because Claude Code's Bash tool already setsid's) Spawn bridges/terminal shells de…
    • Caveats: Revision addressed all three verifier findings with fresh evidence: re-ran the live repro (thr_g3xmvwtd84 / env_ig2nscwucq) capturing pgid/sid — orphan sleep pgid 1593823/sid 1593772 vs bridge+claude pgid/sid 1581708 — plus a strings dump of the claude 2.1.234 binary showing the Bash tool spawns with detached:!0; reordered the fix list so the cwd scan is primary and the group-kill is explicitly sc…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    partial-repro
    on Aug 18, 2026
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

    hostpartial-reproperfworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions