Process/memory leaks: orphaned processes and zombie subagents #101

Closed
opened 2026-01-22 21:56:59 +00:00 by jack · 2 comments
Owner

Origin

Upstream issues #701, #737, #740

Problem

Multiple related issues causing memory and process accumulation:

  1. Orphaned claude processes (#701): 209+ orphaned processes consuming 2.5-3.5GB RAM
  2. Zombie subagents (#737): Worker spawns subagents that don't terminate
  3. Orphaned active sessions (#740): Sessions stuck in 'active' state block pending queue

Symptoms

  • RAM usage grows continuously
  • Many orphaned claude processes visible in task manager
  • Pending message queue gets blocked
  • System becomes sluggish over time

Expected Behavior

  • Subagents terminate when parent completes
  • Sessions properly transition to completed state
  • No orphaned processes accumulate
  • Stable memory usage
  • See CLAUDE.md cleanup command: pkill -f "claude.*--resume"
  • Worker restart: pkill -f "worker-service.cjs --daemon"
## Origin Upstream issues #701, #737, #740 ## Problem Multiple related issues causing memory and process accumulation: 1. **Orphaned claude processes** (#701): 209+ orphaned processes consuming 2.5-3.5GB RAM 2. **Zombie subagents** (#737): Worker spawns subagents that don't terminate 3. **Orphaned active sessions** (#740): Sessions stuck in 'active' state block pending queue ## Symptoms - RAM usage grows continuously - Many orphaned `claude` processes visible in task manager - Pending message queue gets blocked - System becomes sluggish over time ## Expected Behavior - Subagents terminate when parent completes - Sessions properly transition to completed state - No orphaned processes accumulate - Stable memory usage ## Related - See CLAUDE.md cleanup command: `pkill -f "claude.*--resume"` - Worker restart: `pkill -f "worker-service.cjs --daemon"`
Author
Owner

Partial Fix: Orphaned Active Sessions

Found and fixed a bug in the stop hook:

Problem: The stop hook was calling /api/hooks/summarize which only queued summarization but did NOT mark the session as completed. Sessions stayed in 'active' state indefinitely.

Fix: Changed to call /api/hooks/session/end which:

  • Marks session as 'completed'
  • Queues summarization
  • Broadcasts session:ended SSE event

Commit: d995106


Remaining issues (Claude Code bugs, not claude-mem):

  1. Orphaned claude processes - This is a known Claude Code bug with subagents not terminating. Workaround: pkill -f "claude.*--resume"

  2. Zombie subagents - Also a Claude Code issue. Related: https://github.com/anthropics/claude-code/issues/19045

These are upstream Claude Code bugs and cannot be fixed in claude-mem.

## Partial Fix: Orphaned Active Sessions Found and fixed a bug in the stop hook: **Problem:** The stop hook was calling `/api/hooks/summarize` which only queued summarization but did NOT mark the session as completed. Sessions stayed in 'active' state indefinitely. **Fix:** Changed to call `/api/hooks/session/end` which: - Marks session as 'completed' - Queues summarization - Broadcasts session:ended SSE event Commit: d995106 --- **Remaining issues (Claude Code bugs, not claude-mem):** 1. **Orphaned claude processes** - This is a known Claude Code bug with subagents not terminating. Workaround: `pkill -f "claude.*--resume"` 2. **Zombie subagents** - Also a Claude Code issue. Related: https://github.com/anthropics/claude-code/issues/19045 These are upstream Claude Code bugs and cannot be fixed in claude-mem.
Author
Owner

Status Update:

This is an upstream Claude Code issue, not a claude-mem plugin bug. The referenced issues (#701, #737, #740) are in the Claude Code repository itself.

Current Mitigations:

  • CLAUDE.md documents the pkill -f "claude.*--resume" cleanup command
  • Worker restart documented: pkill -f "worker-service.cjs --daemon"

Plugin-side improvements possible:

  1. Worker termination queuing (PR #121) - ensures workers finish tasks before termination
  2. Add periodic cleanup hook to kill orphaned processes automatically
  3. Add memory monitoring to Dashboard to alert users

The core fix must come from Anthropic's Claude Code team. Keeping this issue open to track any plugin-side mitigations we can implement.

**Status Update:** This is an upstream Claude Code issue, not a claude-mem plugin bug. The referenced issues (#701, #737, #740) are in the Claude Code repository itself. **Current Mitigations:** - CLAUDE.md documents the `pkill -f "claude.*--resume"` cleanup command - Worker restart documented: `pkill -f "worker-service.cjs --daemon"` **Plugin-side improvements possible:** 1. ✅ Worker termination queuing (PR #121) - ensures workers finish tasks before termination 2. Add periodic cleanup hook to kill orphaned processes automatically 3. Add memory monitoring to Dashboard to alert users The core fix must come from Anthropic's Claude Code team. Keeping this issue open to track any plugin-side mitigations we can implement.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
customable/claude-mem#101
No description provided.