{"record":{"id":"250a7c6991ca46ac","repo":"vercel/next.js","slug":"heap-usage-is-close-to-the-limit-percentageheap","errorCode":null,"errorMessage":"Heap usage is close to the limit. ${percentageHeapUsed.toFixed(2)}% of heap has been used.","messagePattern":"Heap usage is close to the limit\\. (.+?)% of heap has been used\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/memory/trace.ts","lineNumber":101,"sourceCode":"    info(` - RSS: ${(memoryUsage.rss / 1024 / 1024).toFixed(2)} MB`)\n    info(` - Heap Used: ${(heapUsed / 1024 / 1024).toFixed(2)} MB`)\n    info(\n      ` - Heap Total Allocated: ${(memoryUsage.heapTotal / 1024 / 1024).toFixed(\n        2\n      )} MB`\n    )\n    info(` - Heap Max: ${(heapMax / 1024 / 1024).toFixed(2)} MB`)\n    info(` - Percentage Heap Used: ${percentageHeapUsed.toFixed(2)}%`)\n    info('***************************************')\n    info('')\n\n    if (percentageHeapUsed > HEAP_SNAPSHOT_THRESHOLD_PERCENT) {\n      const distDir = traceGlobals.get('distDir')\n      const heapFilename = join(\n        distDir,\n        `${description.replace(' ', '-')}.heapsnapshot`\n      )\n      warn(\n        bold(\n          `Heap usage is close to the limit. ${percentageHeapUsed.toFixed(\n            2\n          )}% of heap has been used.`\n        )\n      )\n      if (!alreadyGeneratedHeapSnapshot) {\n        warn(\n          bold(\n            `Saving heap snapshot to ${heapFilename}.  ${italic(\n              'Note: this will take some time.'\n            )}`\n          )\n        )\n        v8.writeHeapSnapshot(heapFilename)\n        alreadyGeneratedHeapSnapshot = true\n      } else {\n        warn(","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/lib/memory/trace.ts#L83-L119","documentation":"traceMemoryUsage logs periodic memory stats and, when the percentage of heap used crosses HEAP_SNAPSHOT_THRESHOLD_PERCENT, warns that heap usage is close to the V8 limit before deciding whether to write a .heapsnapshot into distDir.","triggerScenarios":"Thrown at packages/next/src/lib/memory/trace.ts:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the Node heap limit (--max-old-space-size) or find and fix the memory leak before the process runs out of memory."],"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"}