claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Claude Code JavaScript Heap Out of Memory Error

Open ephes opened this issue 6 months ago • 2 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.17 (Claude Code)
  • Operating System: macOS 15.5
  • Terminal: kitty

Bug Description

Claude Code crashes with a JavaScript heap out of memory error after running for an extended period (approximately 14.6 hours based on the GC timestamp).

Steps to Reproduce

  • The error occurred after Claude Code had been running for approximately 52,593,403 ms (≈14.6 hours)
  • The crash happened during normal operation while working in the project
  • The final operation attempted was reading a file using the filesystem API

Expected Behavior

Claude Code should handle long-running sessions without exhausting memory, potentially through:

  • Periodic garbage collection
  • Memory limit management
  • Graceful handling of large file operations

Actual Behavior

The application crashes with SIGABRT when the JavaScript heap limit is reached.

Additional Context

Here's the traceback:

<--- Last few GCs --->

  [45092:0x7fe630008000] 52593403 ms: Mark-Compact (reduce) 4344.4 (4491.8) -> 4343.8 (4348.6) MB, pooled: 0 MB, 132.40 / 0.00 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 484 ms) 
  (average mu = 0.997,
  FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
  ----- Native stack trace -----

   1: 0x10984bd41 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
   2: 0x108514787 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
   3: 0x108514748 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
   4: 0x1086f10ff v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/Cellar/node/24.1.0/bin/node]
   5: 0x1086ef740 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node/24.1.0/bin/node]
   6: 0x1086e6a65 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/24.1.0/bin/node]
   7: 0x1086be558 v8::internal::MaybeHandle<v8::internal::SeqTwoByteString> v8::internal::FactoryBase<v8::internal::Factory>::NewRawStringWithMap<v8::internal::SeqTwoByteString>(int, v8::internal::Tagged<v8::internal::Map>, 
  v8::internal::AllocationType) [/usr/local/Cellar/node/24.1.0/bin/node]
   8: 0x1086cf1dc v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<unsigned char const>, unibrow::Utf8Variant, v8::internal::AllocationType) [/usr/local/Cellar/node/24.1.0/bin/node]
   9: 0x10852b15a v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/usr/local/Cellar/node/24.1.0/bin/node]
  10: 0x108388747 node::fs::ReadFileUtf8(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/Cellar/node/24.1.0/bin/node]
  11: 0x108eb267e Builtins_CallApiCallbackOptimizedNoProfiling [/usr/local/Cellar/node/24.1.0/bin/node]
  fish: Job 1, '/Users/jochen/.claude/local/cla…' terminated by signal SIGABRT (Abort)

ephes avatar Jun 18 '25 23:06 ephes

This should be feeling better in the next release. Thanks for the report!

bcherny avatar Jun 19 '25 05:06 bcherny

Noticed my claude code version was slightly outdated. Ran into the same error today after updating it:

<--- Last few GCs --->

[66855:0x7fd348030000] 44590970 ms: Scavenge 4031.5 (4054.3) -> 4027.8 (4054.3) MB, pooled: 0 MB, 0.47 / 0.00 ms  (average mu = 1.000, current mu = 0.997) allocation failure; 
[66855:0x7fd348030000] 44596978 ms: Mark-Compact 4675.7 (4698.3) -> 4671.2 (4681.8) MB, pooled: 19 MB, 101.10 / 0.00 ms  (average mu = 1.000, current mu = 0.985) allocation failure; scavenge might not succeed

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x106059d41 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
 2: 0x104d22787 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
 3: 0x104d22748 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/24.1.0/bin/node]
 4: 0x104eff0ff v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/Cellar/node/24.1.0/bin/node]
 5: 0x104efd740 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node/24.1.0/bin/node]
 6: 0x104ef4a65 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/24.1.0/bin/node]
 7: 0x104edb951 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/Cellar/node/24.1.0/bin/node]
 8: 0x10527933c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/Cellar/node/24.1.0/bin/node]
 9: 0x105767f76 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/usr/local/Cellar/node/24.1.0/bin/node]
10: 0x126f8cdfb 
fish: Job 1, '/usr/local/Cellar/node/24.1.0/b…' terminated by signal SIGABRT (Abort)

❯ /usr/local/Cellar/node/24.1.0/bin/claude -version
1.0.29 (Claude Code)

ephes avatar Jun 19 '25 11:06 ephes

Any update on the heap out-of-memory issue with Claude Code? I'm unable to install it because of this.

UPDATE

I can confirm , I installed successfully.

x9xhack avatar Jul 26 '25 10:07 x9xhack

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 06 '25 10:12 github-actions[bot]