RSS grows despite stable heap

On-call incidentHard40 min

Your task

A Node.js WebSocket fan-out service's RSS grows ~150MB/hour and the process is recycled by the orchestrator every ~10 hours when it hits 4GB, dropping all live connections at recycle. Heap dashboards from process.memoryUsage() show heapUsed climbing slowly but most of the growth is in 'external' and RSS, not heapUsed. GC runs frequently and reclaims little. A v8 heap snapshot taken 2 hours apart shows the retained-size delta dominated by 'system / Context' and a Map keyed by socket id whose size only ever grows. A feature shipped last week added per-connection metrics buffering. Sessions per day are flat. Triage and fix this.

It covers

  • Nodejs
  • Closure retention
  • Heap snapshot