Skip to content

Node.js Heap Out of Memory: Ineffective Mark-Compacts Near Heap Limit #2650

Closed as duplicate

Description

@Maslol7

Bug Description
<--- Last few GCs --->

[98482:0x7fd548008000] 241880805 ms: Scavenge (interleaved) 3919.9 (4112.4) -> 3904.0 (4112.4) MB, pooled: 1 MB, 4.24 / 0.00 ms (average mu = 0.130, current mu = 0.068) allocation failure;
[98482:0x7fd548008000] 241882166 ms: Mark-Compact 3921.1 (4113.6) -> 3905.2 (4106.6) MB, pooled: 8 MB, 1345.30 / 0.00 ms (average mu = 0.114, current mu = 0.096) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

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

1: 0x10437a4f5 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/23.6.1/bin/node]
2: 0x104533bcb v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/Cellar/node/23.6.1/bin/node]
3: 0x1046f2e27 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/Cellar/node/23.6.1/bin/node]
4: 0x1046f9dc8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_10::operator()() const [/usr/local/Cellar/node/23.6.1/bin/node]
5: 0x1046f3169 void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_10>(heap::base::Stack*, void*, void const*) [/usr/local/Cellar/node/23.6.1/bin/node]
6: 0x10428839b PushAllRegistersAndIterateStack [/usr/local/Cellar/node/23.6.1/bin/node]
7: 0x1046efe8d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node/23.6.1/bin/node]
8: 0x1046e9647 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/23.6.1/bin/node]
9: 0x1046ea04c v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/23.6.1/bin/node]
10: 0x1046db9f9 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/Cellar/node/23.6.1/bin/node]
11: 0x1049bb3e6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/Cellar/node/23.6.1/bin/node]
12: 0x104152df6 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/usr/local/Cellar/node/23.6.1/bin/node]
13: 0x1193ae67d
zsh: abort /Users/omristein/.claude/local/claude

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 1.0.35
  • Feedback ID: 56bf5482-5750-44f4-a4c3-bbac9b7f2d7f

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:882:11)\n    at execSync (node:child_process:954:15)\n    at TZ (file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:700:3921)\n    at file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:622:9014\n    at Q (file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:526:17199)\n    at VX (file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:622:8160)\n    at nS (file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:622:7241)\n    at f9 (file:///Users/omristein/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:622:11408)","timestamp":"2025-06-27T04:22:44.842Z"}]

Activity

  1. omayhemo commented on Jun 27, 2025

    @omayhemo

    +1

  2. kaikyMoura commented on Jul 12, 2025

    @kaikyMoura

    This issue could be caused by many things...

    In my case, it happened when I tried to run a unit test. Jest was loading the entire application configuration, and I had mistakenly set the cache module as global in my NestJS AppModule. That turned out to be the problem — it was keeping heavy dependencies in memory and causing the heap error.

    For others facing the same issue, it's likely that some dependency is consuming too much memory during Jest’s initialization. To prevent problems like this in the future, consider using Node.js profiling tools:
    https://nodejs.org/en/learn/getting-started/profiling

    You can also debug it with:

    node --inspect-brk --max-old-space-size=4096 ./node_modules/.bin/jest --runInBand

    After running this, you’ll see a link like chrome-devtools://... — open it in Chrome and:

    1. Open Chrome DevTools
    2. Paste the URL from the terminal
    3. Go to the Memory tab
    4. Click Take snapshot
    5. Look for objects using the most memory

    More resources:

    Node memory issues:
    https://stackoverflow.com/questions/46688918/nodejs-memory-allocation-failure

    If you're using Google APIs:
    googleapis/google-api-nodejs-client#2187
    https://stackoverflow.com/questions/56599477/typescript-googleapis-surge-in-memory-used

    If you're using NestJS:
    https://www.reddit.com/r/node/comments/1b2qsmd/my_nestjs_application_heap_memory_consumption_is/

  3. github-actions commented on Aug 5, 2025

    @github-actions

    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.

  4. locked as resolved and limited conversation to collaborators on Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions