Skip to content

Memory leak in native addons: ~18 GB/hour growth, RSS reaches 2 GB in 7 minutes #32752

@JahJajaka

Description

@JahJajaka

Description

Claude Code CLI process exhibits aggressive memory growth (~18 GB/hour), reaching ~2 GB RSS in under 7 minutes. The diagnostics indicate the leak is in native memory (outside V8 heap), likely in native addons such as node-pty.

Diagnostics (/heapdump output)

{
  "trigger": "manual",
  "uptimeSeconds": 404,
  "memoryUsage": {
    "heapUsed": 197405793,
    "heapTotal": 71928832,
    "external": 151865422,
    "arrayBuffers": 54231508,
    "rss": 2142371840
  },
  "memoryGrowthRate": {
    "bytesPerSecond": 5301361,
    "mbPerHour": 18200
  },
  "v8HeapStats": {
    "heapSizeLimit": 26947584000,
    "mallocedMemory": 197668190,
    "peakMallocedMemory": 2694758400
  },
  "analysis": {
    "potentialLeaks": [
      "Native memory > heap - leak may be in native addons (node-pty, sharp, etc.)",
      "High memory growth rate: 18200.8 MB/hour"
    ]
  },
  "platform": "darwin",
  "nodeVersion": "v24.3.0",
  "ccVersion": "2.1.71"
}

Key observations

  • JS heap is only ~188 MB, but RSS is ~2 GB — the gap is in native/external memory
  • external memory (151 MB) and arrayBuffers (52 MB) suggest buffer accumulation
  • peakMallocedMemory (2.7 GB) vs current mallocedMemory (197 MB) shows large allocations happened and were freed, but RSS wasn't returned to OS
  • Growth rate of ~5.3 MB/s is unsustainable for long sessions

Environment

  • macOS (Darwin)
  • Node.js v24.3.0
  • Claude Code v2.1.71

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already existsperf:memoryplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions