[BUG] 2 hour session exhausts 4G and crashes claude code 2.0.28/2.0.29

Resolved 💬 5 comments Opened Oct 31, 2025 by dthennessey Closed Jan 10, 2026

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?

Bug Report: Claude Code Client Memory Leak - OOM Crash After 2 Hours

Description

Claude Code client crashed with "JavaScript heap out of memory" error after running for approximately 2 hours overnight. The process
consumed ~4GB of heap memory before exhausting available space.

Environment

  • Platform: Linux (WSL2)
  • OS Version: 5.15.167.4-microsoft-standard-WSL2
  • Working Directory: /mnt/c/Development/Pareto/ParetoDevEnv/workspaces/eclipse-ws-01/VirtualCoaching
  • Project Type: Java/TypeScript mixed codebase

Reproduction Steps

  1. Launch Claude Code client
  2. Work on project for initial session
  3. Leave client running overnight (~2 hours)
  4. Client crashes with OOM error

Expected Behavior

Client should maintain stable memory usage during idle/long-running sessions, with proper garbage collection preventing unbounded
memory growth.

Actual Behavior

Memory grew from normal levels to 3.9-4.1 GB over ~2 hours, with GC becoming ineffective at reclaiming memory.

Error Output

<--- Last few GCs --->

[382898:0x18224f80] 7564134 ms: Scavenge 3923.7 (4112.6) -> 3899.8 (4100.0) MB, 10.00 / 0.01 ms (average mu = 0.318, current mu =
0.313) allocation failure;
[382898:0x18224f80] 7564179 ms: Scavenge 3920.7 (4104.7) -> 3904.6 (4101.5) MB, 9.41 / 0.01 ms (average mu = 0.318, current mu =
0.313) allocation failure;
[382898:0x18224f80] 7564204 ms: Scavenge 3918.0 (4101.5) -> 3906.2 (4101.7) MB, 8.93 / 0.01 ms (average mu = 0.318, current mu =
0.313) allocation failure;

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

1: 0xb76dc5 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [claude]
2: 0xee6020 v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, v8::OOMDetails const&) [claude]
3: 0xee6307 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, v8::OOMDetails const&) [claude]
4: 0x10f7f55 [claude]
5: 0x10f84e4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [claude]
6: 0x110f3d4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason,
char const*) [claude]
7: 0x110fbec v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason,
v8::GCCallbackFlags) [claude]
8: 0x10e5ef1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType,
v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [claude]
9: 0x10e7085 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType,
v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [claude]
10: 0x10c37a6 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [claude]
11: 0x10b53d4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType,
v8::internal::Map, v8::internal::AllocationAlignment) [claude]
12: 0x10b86e7 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [claude]
13: 0x10cec1b v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [claude]
14: 0xef88b2 v8::String::NewFromUtf8(v8::Isolate, char const, v8::NewStringType, int) [claude]
15: 0xcbb209 [claude]
16: 0x7fd4eb60d546
Aborted (core dumped)

Analysis

  • Runtime: 7564 seconds (~126 minutes / 2.1 hours)
  • Peak Memory: ~4GB heap
  • GC Pattern: Frequent scavenges unable to reclaim significant memory
  • Crash Location: During UTF-8 string allocation (frame 13-14)
  • Symptom: Classic memory leak - linear growth over time

Potential Leak Sources

Based on the crash pattern, likely culprits:

  1. Unbounded message/conversation history accumulation
  2. File watcher events not being cleaned up
  3. Tool result buffering without size limits
  4. WebSocket/IPC connection handlers accumulating
  5. String concatenation/logging in hot paths

Workaround

Restart Claude Code client every 1-2 hours during long sessions.

Additional Context

This issue started occurring in recent versions. The client was idle for most of the 2-hour period but maintained active file system
connections to the project directory.

What Should Happen?

no crash :)

Error Messages/Logs

<--- JS stacktrace --->

  FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
  ----- Native stack trace -----

   1: 0xb76dc5 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [claude]
   2: 0xee6020 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [claude]
   3: 0xee6307 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [claude]
   4: 0x10f7f55  [claude]
   5: 0x10f84e4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [claude]
   6: 0x110f3d4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason,
  char const*) [claude]
   7: 0x110fbec v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason,
  v8::GCCallbackFlags) [claude]
   8: 0x10e5ef1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType,
  v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [claude]
   9: 0x10e7085 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType,
  v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [claude]
  10: 0x10c37a6 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [claude]
  11: 0x10b53d4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType,
  v8::internal::Map, v8::internal::AllocationAlignment) [claude]
  12: 0x10b86e7 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [claude]
  13: 0x10cec1b v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [claude]
  14: 0xef88b2 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [claude]
  15: 0xcbb209  [claude]
  16: 0x7fd4eb60d546
  Aborted (core dumped)

Steps to Reproduce

Just use normally for ~2 hours

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.27

Claude Code Version

2.0.28

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

_No response_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗