vercel/next.js · error

Heap usage is close to the limit. ${percentageHeapUsed.toFix

Error message

Heap usage is close to the limit. ${percentageHeapUsed.toFixed(2)}% of heap has been used.

What it means

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.

Source

Thrown at packages/next/src/lib/memory/trace.ts:101

    info(` - RSS: ${(memoryUsage.rss / 1024 / 1024).toFixed(2)} MB`)
    info(` - Heap Used: ${(heapUsed / 1024 / 1024).toFixed(2)} MB`)
    info(
      ` - Heap Total Allocated: ${(memoryUsage.heapTotal / 1024 / 1024).toFixed(
        2
      )} MB`
    )
    info(` - Heap Max: ${(heapMax / 1024 / 1024).toFixed(2)} MB`)
    info(` - Percentage Heap Used: ${percentageHeapUsed.toFixed(2)}%`)
    info('***************************************')
    info('')

    if (percentageHeapUsed > HEAP_SNAPSHOT_THRESHOLD_PERCENT) {
      const distDir = traceGlobals.get('distDir')
      const heapFilename = join(
        distDir,
        `${description.replace(' ', '-')}.heapsnapshot`
      )
      warn(
        bold(
          `Heap usage is close to the limit. ${percentageHeapUsed.toFixed(
            2
          )}% of heap has been used.`
        )
      )
      if (!alreadyGeneratedHeapSnapshot) {
        warn(
          bold(
            `Saving heap snapshot to ${heapFilename}.  ${italic(
              'Note: this will take some time.'
            )}`
          )
        )
        v8.writeHeapSnapshot(heapFilename)
        alreadyGeneratedHeapSnapshot = true
      } else {
        warn(

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Increase the Node heap limit (--max-old-space-size) or find and fix the memory leak before the process runs out of memory.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/next/src/lib/memory/trace.ts:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/250a7c6991ca46ac. Report an issue: GitHub.