nextjs - 💡(How to fix) Fix @next/swc-darwin-arm64 allocates multi-GB non-reclaimable IOAccelerator memory during Turbopack compilation on Apple Silicon [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#92052Fetched 2026-04-08 01:44:59
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2closed ×1commented ×1

Root Cause

On Apple Silicon, IOAccelerator memory competes with GPU, media engine, and system processes for the same unified physical RAM. A developer running next dev on a 16 GB MacBook with a moderately-sized app can lose 8-14 GB to non-reclaimable allocations they can't see, control, or limit.

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.x
  Bun: 1.2.x
  npm: 10.x
Relevant Packages:
  next: 16.2.1
  react: 19.2.3
  react-dom: 19.2.3
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/isaacwasserman/nextjs-ioaccel-repro

To Reproduce

  1. Clone the repo and bun install (or npm install)
  2. bun dev (or npx next dev)
  3. Run vmmap $(pgrep -f next-server) | grep "^IOAccelerator" — observe 2.0 GB allocated before opening any page
  4. Visit http://localhost:3099/chat/test
  5. Re-run vmmap — IOAccelerator has grown to 3.5 GB
  6. Wait 2+ minutes, re-run vmmap — nothing is freed

Current vs. Expected behavior

Current: The @next/swc-darwin-arm64 native binary allocates IOAccelerator (MAP_JIT) memory regions during Turbopack compilation that grow monotonically and are never freed. A 5-page app with standard SaaS dependencies (better-auth, drizzle-orm, AWS SDK, chart.js, ag-charts, AI SDKs) reaches 3.5 GB of permanent IOAccelerator allocations. A production app with 27 pages reaches 13.9 GB.

Expected: Compilation artifacts should be freed after compilation completes, or at minimum be bounded by a configurable limit.

Key findings

The SWC binary is the source (isolated with controls):

ProcessIOAccelerator
Bare Node.js0 MB
Node.js + require(next-swc.node)136 MB + 896 MB reserved
Next.js dev (after compiling 5 pages)3,500 MB

Not runtime-specific: Tested with both Node.js and Bun — identical results. The allocations come from the native SWC binary, not the JavaScript runtime.

Never freed: After compilation completes, IOAccelerator regions persist for the lifetime of the process. Tested with 120+ seconds of idle — zero bytes reclaimed.

Invisible to Node.js tools: process.memoryUsage() doesn't report it. --max-old-space-size doesn't limit it. experimental.turbopackMemoryLimit is accepted in config but not wired to the native binary.

Scales linearly with app size: Each compilation context (proxy, instrumentation, API route, server component, client component) creates additional permanent 128 MB slab allocations. More pages and deeper dependency trees = more slabs.

Why this matters

On Apple Silicon, IOAccelerator memory competes with GPU, media engine, and system processes for the same unified physical RAM. A developer running next dev on a 16 GB MacBook with a moderately-sized app can lose 8-14 GB to non-reclaimable allocations they can't see, control, or limit.

Related issues

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 22.x
  Bun: 1.2.x
  npm: 10.x
Relevant Packages:
  next: 16.2.1
  react: 19.2.3
  react-dom: 19.2.3

Which area(s) are affected? (Select all that apply)

Turbopack, Performance

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The reproduction repo includes a 5-page app with standard SaaS dependencies (auth, database ORM, AWS SDK, AI SDKs, charting libraries). The architecture mirrors common patterns: proxy with auth checks, instrumentation for tracing, catchall API route for RPC, and pages with server components + heavy client components. Nothing unusual — this is what a typical production Next.js app looks like.

extent analysis

Fix Plan

To address the issue of monotonically growing IOAccelerator memory allocations, we need to focus on the @next/swc-darwin-arm64 native binary. Since the allocations come from the native SWC binary and not the JavaScript runtime, we'll explore potential fixes related to SWC configuration and usage.

Step 1: Update SWC Configuration

Try updating the SWC configuration to use a more efficient or memory-conscious setup. This might involve tweaking the swc options in your next.config.js file.

// next.config.js
module.exports = {
  //... other configurations
  swc: {
    // Experiment with different configurations to reduce memory usage
    // For example, disabling unnecessary plugins or features
    // jsc: {
    //   parser: {
    //     syntax: 'ecmascript',
    //     dynamicImport: true,
    //   },
    //   transform: {
    //     react: {
    //       runtime: 'automatic',
    //     },
    //   },
    // },
  },
}

Step 2: Implement Memory Limits

Although --max-old-space-size doesn't limit IOAccelerator allocations, and experimental.turbopackMemoryLimit is not wired to the native binary, we should explore if there are any other memory limit configurations available for SWC or Turbopack that could help bound these allocations.

Step 3: Periodic Process Restart

As a temporary workaround, consider implementing a periodic restart of the development server to mitigate the issue of growing memory allocations. This could be automated using scripts or tools that monitor the process's memory usage and restart it when necessary.

Step 4: Monitor and Report

Continuously monitor the memory usage of your development server and report any findings or patterns that could help in addressing the root cause of the issue. This includes testing different scenarios, dependencies, and configurations to see how they impact IOAccelerator memory allocations.

Verification

To verify that the implemented fixes are working, follow these steps:

  • Run vmmap $(pgrep -f next-server) | grep "^IOAccelerator" before and after applying the fixes to compare the IOAccelerator memory allocations.
  • Monitor the development server's memory usage over time to ensure that the allocations are bounded or reduced.
  • Test the application with various scenarios and dependencies to confirm that the fixes do not introduce any regressions.

Extra Tips

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix @next/swc-darwin-arm64 allocates multi-GB non-reclaimable IOAccelerator memory during Turbopack compilation on Apple Silicon [1 comments, 1 participants]