{"record":{"id":"e3c2eeff71e5b1cf","repo":"vercel/next.js","slug":"received-sigusr2-signal-generating-heap-snapshot","errorCode":null,"errorMessage":"Received SIGUSR2 signal. Generating heap snapshot. Note: this will take some time.","messagePattern":"Received SIGUSR2 signal\\. Generating heap snapshot\\. Note: this will take some time\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/memory/startup.ts","lineNumber":23,"sourceCode":"import { startPeriodicMemoryUsageTracing } from './trace'\n\nexport function enableMemoryDebuggingMode(): void {\n  // This will generate a heap snapshot when the program is close to the\n  // memory limit. It does not give any warning to the user though which\n  // can be jarring. If memory is large, this may take a long time.\n  if ('setHeapSnapshotNearHeapLimit' in v8) {\n    v8.setHeapSnapshotNearHeapLimit(1)\n  }\n\n  // This flag will kill the process when it starts to GC thrash when it's\n  // close to the memory limit rather than continuing to try to collect\n  // memory ineffectively.\n  v8.setFlagsFromString('--detect-ineffective-gcs-near-heap-limit')\n\n  // This allows users to generate a heap snapshot on demand just by sending\n  // a signal to the process.\n  process.on('SIGUSR2', () => {\n    warn(\n      `Received SIGUSR2 signal. Generating heap snapshot. ${italic(\n        'Note: this will take some time.'\n      )}`\n    )\n    v8.writeHeapSnapshot()\n  })\n\n  startObservingGc()\n  startPeriodicMemoryUsageTracing()\n\n  warn(\n    `Memory debugging mode is enabled. ${italic(\n      'Note: This will affect performance.'\n    )}`\n  )\n  info(\n    ' - Heap snapshots will be automatically generated when the process reaches more than 70% of the memory limit and again when the process is just about to run out of memory.'\n  )","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/lib/memory/startup.ts#L5-L41","documentation":"In enableMemoryDebuggingMode, a SIGUSR2 handler is registered so a V8 heap snapshot can be triggered on demand; it warns that writing the snapshot is slow before performing it. Part of Next.js memory debugging instrumentation, not an error.","triggerScenarios":"Thrown at packages/next/src/lib/memory/startup.ts:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the heap snapshot to finish; it is written to the indicated file for analysis."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}