[BUG] Memory leak: Single agent task consumes 15+ GB RAM when using custom orchestrator agent
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using a custom orchestrator agent via a slash command, a single claude process consumes all available RAM (15+ GB) within ~2 minutes, causing the system to become completely unresponsive.
The memory leak occurs in a SINGLE process - not from spawning multiple parallel tasks. The orchestrator task itself consumes all RAM before it even gets to delegate work to other agents.
Evidence from ps aux during the issue:
- Single claude process: 91.8% MEM, 15.4 GB RSS, 90 GB VSZ
- Process status: Dl+ (uninterruptible sleep)
- System: 16 GB RAM + 8 GB Swap completely exhausted
What Should Happen?
The orchestrator agent task should execute with reasonable memory usage (< 1 GB) and successfully delegate tasks to specialist agents without exhausting system memory.
Direct delegation to individual agents (e.g., /delegate @backend-developer) works fine with normal memory usage - only the orchestrator pattern triggers the leak.
Error Messages/Logs
No error messages - system becomes unresponsive before any error can be shown.
Memory monitoring log captured before freeze:
=== Mon Dec 15 14:46:13 UTC 2025 ===
USER PID %CPU %MEM VSZ RSS STAT COMMAND
elzorro 29858 72.0 91.8 90395356 15417580 Rl+ claude
elzorro 1127 6.5 2.7 75158276 466408 Sl+ claude
total used free shared buff/cache available
Memory: 16Gi 15Gi 129Mi 3.1Mi 553Mi 680Mi
Swap: 8.0Gi 1.3Gi 6.7Gi
=== Mon Dec 15 14:46:15 UTC 2025 ===
Memory: 16Gi 15Gi 131Mi 3.1Mi 541Mi 670Mi
Swap: 8.0Gi 1.5Gi 6.5Gi
The problematic process (PID 29858) was the orchestrator task, consuming 15.4 GB while the main claude session (PID 1127) used only 466 MB.
Steps to Reproduce
- Create custom agents in ~/.claude/agents/:
- orchestrator.md (with tools: Read, Grep, Glob, TodoWrite, Task, TaskOutput)
- Specialist agents (backend-developer.md, frontend-developer.md, etc.)
- Create ~/.claude/commands/start.md that launches orchestrator:
Task(
subagent_type="orchestrator",
prompt="[orchestration instructions ~100 lines]",
description="Orchestrator"
)
- Navigate to any project directory (even empty)
- Run: /start Create a simple FastAPI app
- Watch memory consumption - within 2 minutes RAM is exhausted
Workaround: Using direct /delegate @agent-name works fine - only the orchestrator pattern causes the leak.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.67
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
- Claude Code Version: 2.0.67
- OS: Debian GNU/Linux 13 (trixie)
- Kernel: Linux 6.17.2-2-pve x86_64
- RAM: 16 GB + 8 GB Swap
- Environment: LXC Container (Proxmox)
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗