Memory leak causing V8 OOM crashes (SIGABRT) on extended sessions
Resolved 💬 16 comments Opened Jan 13, 2026 by jc90069 Closed Apr 16, 2026
Description
Claude Code sessions are crashing due to V8 heap exhaustion (Out of Memory). The Node.js process accumulates memory until garbage collection fails, triggering abort().
Environment
- Claude Code version: 2.1.6
- Node version: v23.6.0
- OS: macOS 26.0.1 (Darwin 25.0.0)
- Platform: Apple Silicon (M4 Max, arm64)
- RAM: 64GB
Crash Evidence
Multiple crash reports in ~/Library/Logs/DiagnosticReports/node-*.ips showing the same pattern:
"termination": {
"code": 6,
"namespace": "SIGNAL",
"indicator": "Abort trap: 6"
}
"asi": {"libsystem_c.dylib": ["abort() called"]}
Stack trace:
node::OOMErrorHandler(char const*, v8::OOMDetails const&)
v8::Utils::ReportOOMFailure(v8::internal::Isolate*, ...)
v8::internal::V8::FatalProcessOutOfMemory(...)
v8::internal::Heap::FatalProcessOutOfMemory(char const*)
v8::internal::Heap::CheckIneffectiveMarkCompact(...)
v8::internal::Heap::CollectGarbage(...)
Reproduction
- Run multiple Claude Code sessions in parallel (3-4 terminal tabs)
- Use sessions for extended periods (30+ minutes) with moderate tool usage
- Sessions crash simultaneously when heap is exhausted
Observations
- 10 crash reports in a single day
- Multiple sessions crash at the exact same millisecond (shared heap?)
- Debug logs show normal operation until abrupt termination (no graceful SessionEnd logged)
- Sessions that logged
SessionEnd with query: othervs sessions that just died suggest two crash modes
Workaround
Increasing Node.js heap size delays the crash:
export NODE_OPTIONS="--max-old-space-size=8192"
Crash Report Timestamps (2026-01-13)
- 16:23:42
- 16:39:01
- 18:28:48 (3 reports)
- 19:35:29
- 19:45:42
- 21:36:06
- 21:48:44
- 21:48:45
Additional Context
This appears to be a memory leak rather than legitimate memory usage - 64GB machine shouldn't be hitting OOM on CLI tool sessions. Possibly related to:
- Conversation context accumulation
- MCP server connections
- Subagent spawning
- Debug logging
Happy to provide full crash reports if helpful.
---
🤖 Generated with Claude Code
16 Comments
Experiencing the same crash, but specifically on idle sessions (sessions left unused for extended periods).
Environment:
This happens even when the session is mostly idle with no active tool usage. The crash timing suggests background processes (statusline updates, MCP polling, event listeners) are continuously accumulating memory without proper garbage collection? Some type of passive background operations are leaking memory over time.
Additional Evidence: Crash during active tool use (2026-01-16)
Adding another data point - crash occurred during active tool processing (not idle), specifically while processing Grep results after a conversation compaction.
Environment
Session State at Crash
| Metric | Value |
|--------|-------|
| Session duration | ~29 minutes |
| Session file size | 35MB (1,467 JSONL entries) |
| Compaction events | 7 auto-compactions |
| Pre-crash token count | 155,559 tokens |
| PID | 10013 |
Crash Sequence
SetConstructor- V8 trying to build Set from tool resultsStack (same pattern as OP)
Memory from vmSummary
Key Observation: Compaction Accumulation
The session went through 7 compaction cycles:
Crash Report
Full
.ipsavailable:node-2026-01-16-130950.000.ips(38KB)Workaround Confirmed
NODE_OPTIONS="--max-old-space-size=8192"does help, but this feels like treating the symptom rather than the cause.---
This crash pattern (multiple compactions → accumulated state → OOM) might be worth investigating separately from the idle-session leak that @bob-bot mentioned.
Adding another data point - hit the same OOM crash on v2.1.12 (Node 24.11.1, macOS, M-series).
Trigger: Spawned a super-coder Task agent that invoked Skill(commit) mid-execution. Crashed ~9 min into the session. Context was only at 81% when it died, so not context exhaustion.
Heap state at crash:
8109.9 (8176.6) -> 8099.2 (8253.1) MB
average mu = 0.372, current mu = 0.381
Same "Ineffective mark-compacts near heap limit" pattern as OP.
Stack excerpt:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
node::OOMErrorHandler → v8::internal::V8::FatalProcessOutOfMemory → Heap::CollectGarbage
Seems consistent with agent context accumulation mentioned in #8978 and parallel agent memory issues in #8382. The fact it's still reproducing on 2.1.12 (vs OP's 2.1.6) suggests it hasn't been addressed yet.
Happy to provide full stack trace or debug logs if helpful.
If the Anthropic team still has issues for reproducing the issue. We have the issue reliably on several different (M Series) Mac machines when running the following Claude command with a sub agent.
The MCP tools the agent is using are from https://github.com/laravel/boost. The easiest way to set this up is to create a fresh Laravel Project with Boost installed using the Laravel Installer.
https://laravel.com/docs/12.x/installation#creating-a-laravel-project
Command:
````markdown
Code Review
Review code changes against project standards with focus on simplification and avoiding unnecessary complexity.
Arguments
$ARGUMENTS- Optional base branch to compare against (default: develop)Workflow
Step 1: Get Changes
Run git diff to capture all changes with context:
If no changes are found, inform the user and exit.
Step 2: Identify Patterns for Documentation Search
From the diff output, identify:
Step 4: Invoke Code Review Agent
Use the
code-revieweragent to review the changes. The agent will:Step 5: Present Results
Present the review findings in this format:
For each simplification opportunity, provide:
Str::slug()helper")Key Principles
Code Review Summary
🔴 Critical Issues (Must Fix)
[Issues that violate CLAUDE.md hard rules, could cause bugs, data corruption, or security vulnerabilities]
🔵 Simplification Opportunities (Reinvented Wheels)
[Code that could use Laravel features instead - point to which feature to investigate, don't provide replacement code]
🟡 Improvements (Should Fix)
[Best practice violations and code quality issues]
🟢 Suggestions (Nice to Have)
[Minor enhancements and style improvements]
✅ What's Done Well
[Acknowledge good patterns and practices observed]
````
Came upon this bug report when searching for symptoms I've been seeing the past week or so. fwiw probably I am seeing the same issue. I'm running the "native" claude client, latest version, on WSL2/ARM.
Clarification: This is JSC (JavaScriptCore), not V8, on current builds
A note that may reframe the diagnosis and workarounds for this issue.
The runtime changed
Claude Code v2.1.44 (and likely several versions prior) ships as a compiled Bun binary — a self-contained 175 MB Mach-O arm64 executable. The JavaScript engine is JavaScriptCore (JSC), not V8. I confirmed this via binary inspection: the binary contains Bun FFI signatures,
BUN_JSC_env var parsing, and--smolflag strings.The V8-specific stack traces in the original report (v2.1.6) may predate the Bun migration, or V8 symbol names may persist in Bun's compatibility layer. Either way, the memory management subsystem in current builds is JSC, not V8.
Correct environment variable
The
NODE_OPTIONS="--max-old-space-size=..."workaround has no effect on the Bun/JSC build. The equivalent is:This tells JSC the machine has 16 GB of RAM, triggering aggressive garbage collection at ~80% (~12.8 GB). Without it, JSC on a 64 GB machine (like the OP's M4 Max) won't GC aggressively until ~51 GB — essentially allowing unbounded growth until OOM.
Tune the value to your setup:
BUN_JSC_forceRAMSize=17179869184(16 GB)BUN_JSC_forceRAMSize=17179869184(16 GB)BUN_JSC_forceRAMSize=8589934592(8 GB)Supporting data
I'm running 13 concurrent Claude v2.1.44 sessions on macOS Tahoe 26.2 (M2 Pro, 32 GB). Per-session RSS ranges from 315 MB to 771 MB, totalling ~5.9 GB across all 13. With macOS memory compressor achieving 2.4x compression, swap usage stays at only 233 MB after 21h uptime. The sessions are stable.
Detailed data and
BUN_JSC_forceRAMSizedocumentation in my comment on the primary tracker: #4953.Follow-up: Correction on BUN_JSC_forceRAMSize + better workaround
After controlled testing, I need to update my earlier recommendation.
BUN_JSC_forceRAMSize has limited effect
Stress tests with JS string allocations (which model the actual leak — conversation context and tool output) showed identical RSS with and without
BUN_JSC_forceRAMSize. The env var adjusts JSC's GC aggressiveness for heap-managed objects, but Claude Code's memory growth is primarily in native string backing stores (mimalloc), which bypass JSC's GC entirely.More effective workaround
The better approach is to reduce context accumulation directly:
This triggers context compaction at 50% of the context window instead of the default ~83.5%. Verified in the v2.1.44 binary source. Since this issue's crash data shows session files growing to 35 MB with 1,467 JSONL entries before OOM, earlier compaction directly addresses the root cause.
Installation method note
This issue's original crash traces show V8 symbols (
v8::internal::Heap::FatalProcessOutOfMemory), indicating a Node.js installation. For those users:NODE_OPTIONS="--max-old-space-size=8192"— V8 heap limit (relevant)BUN_JSC_forceRAMSize— irrelevant (JSC only, Bun native binary only)CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50— works on both installation typesFor users on the native binary (v2.1.x installed via
claude update), the V8 options don't apply, butCLAUDE_AUTOCOMPACT_PCT_OVERRIDEdoes.Correction to my previous comment
Retracting the
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50recommendation.After further testing, lowering the autocompact threshold significantly degrades session quality — context gets compacted too aggressively, leading to lost reasoning chains, degraded multi-turn performance, and reduced reliability. The default (~83.5%) is there for a reason.
Updated honest assessment — no user-side configuration fix currently exists for this leak:
BUN_JSC_forceRAMSize— confirmed ineffective (JS string allocations go to native memory via mimalloc, bypassing JSC GC entirely)CLAUDE_AUTOCOMPACT_PCT_OVERRIDE— trades memory for intelligence; not a viable workaroundNODE_OPTIONS— no effect (Claude Code is Bun/JSC, not Node.js/V8)What actually helps (operational mitigations only):
/exitbefore closing terminals)ps -eo rss,args | grep claude--smolflag for lightweight tasksThe core leak (unbounded native memory retention from subprocess stdout/stderr) needs an architectural fix from Anthropic. No env var tuning addresses it.
Nice to see someone do some diagnosis. I'm curious why changing GC tuning changes program behavior (besides making it die sooner/later). Is there some sort of weak reference mechanism in use here?
Experienced OOM kill during a session where I wrote an rsync script and then ran it. The rsync progress output accumulated in the session, causing the Claude process to grow to 7.6 GiB RSS (98 GiB virtual) before being killed by the Linux OOM killer.
System: 16 GiB RAM + 20 GiB swap (both exhausted). Claude Code on Arch Linux.
The session itself was not complex — just editing a script then running it. The memory growth appears to come from ingesting verbose command output over time.
hit this on long sessions with lots of MCP tool calls. what helped us was using the heap snapshot approach - take heap dumps 10 minutes apart and diff by type/size to find what's growing. in our case it was accumulated tool results that weren't being GC'd. shorter sessions with the conversation compression feature seem to reduce the frequency but don't eliminate it completely.
for the heap snapshot debugging approach on macOS: https://github.com/m13v/fazm - we document the heap diffing technique in our CLAUDE.md for diagnosing memory leaks in long-running processes.
fwiw I haven't encountered this issue recently but that may be due to evasive action on my side: not using ARM machines, and never letter a session run too long.
interesting that ARM might be a factor. we're on M-series Macs exclusively and see it on long sessions with lots of MCP tool calls. the conversation compression feature has helped reduce frequency for us but it's not gone completely. curious if you've noticed it correlating with any specific tool usage patterns.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.