Skip to content

@next/swc-darwin-arm64 allocates multi-GB non-reclaimable IOAccelerator memory during Turbopack compilation on Apple Silicon #92055

Closed

Description

@isaacwasserman

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 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.

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

Process IOAccelerator
Bare Node.js 0 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.

Never freed: After compilation completes, IOAccelerator regions persist for the lifetime of
the process. Tested with 120+ seconds 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.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.17.0
Relevant Packages:
  next: 16.2.1
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Turbopack, SWC, Performance

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

next dev (local)

Additional context

Related issues:

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.

Activity

  1. added
    Performance
    SWC
    Turbopack
    on Mar 28, 2026
  2. self-assigned this
    on Apr 8, 2026
  3. tjb9dc commented on Apr 10, 2026

    @tjb9dc

    Seeing this same thing on Next.js 16.1.1 with a larger but not very big app (56 pages, 58 API routes).

    If helpful:

    Setup:

    • Next.js 16.1.1 (Turbopack default)
    • Node.js 22.22.0
    • macOS Darwin 25.3.0, Apple Silicon
    • Monorepo with pnpm, ~114 routes total (56 pages + 58 API routes)

    Measurements after navigating several pages:

    footprint output:

    node [PID]: 64-bit    Footprint: 2981 MB
    
      Dirty      Clean  Reclaimable    Regions    Category
    2342 MB        0 B          0 B         86    IOAccelerator
     495 MB        0 B      1328 KB       1709    app-specific tag 16
      62 MB        0 B          0 B         21    MALLOC_SMALL
    

    process.memoryUsage() (via inspector) with the same process:

    {"heapUsed":"578MB","heapTotal":"619MB","rss":"4698MB","external":"5MB","arrayBuffers":"1MB"}

    4.1GB gap between RSS and V8 heap, almost entirely IOAccelerator. Confirmed next-swc.darwin-arm64.node is the only native addon loaded.

  4. pastarita commented on Apr 11, 2026

    @pastarita

    Confirming this at production scale — 769 routes (522 page + 247 API) in a TurboRepo monorepo with 259 transpilePackages. This is the same IOAccelerator pattern at a much larger route count.

    Environment

    • Mac Mini M4, 16 GB unified memory
    • macOS Sequoia 15.3.1 (Darwin 24.3.0)
    • Node.js v22.22.2
    • Next.js 16.2.0 (also tested 16.1.6, 16.0.7, 15.5.15)
    • Bun 1.3.5 as package manager (real Node.js for next dev)
    • 259 transpilePackages, 228 workspace packages, 164 outputFileTracingExcludes

    Key Findings

    1. Version bisect — bug predates Next.js 16

    Next.js Version IOAccelerator at kill Turbopack/Webpack
    16.2.0 4,634 MB Turbopack
    16.1.6 4,643 MB Turbopack
    16.0.7 4,655 MB Turbopack
    15.5.15 4,226 MB Turbopack
    16.2.0 5,915 MB Webpack

    All versions show identical pattern: ~1.1GB plateau for 20-30s, then explosion to 4GB+ in 2-4 seconds.

    2. Webpack mode is WORSE, not better

    Same IOAccelerator pattern under next dev --no-turbo:

    • Turbopack: IOAccelerator = 4,634 MB at kill
    • Webpack: IOAccelerator = 5,915 MB at kill

    This means the leak is in shared Next.js infrastructure (route discovery, file watching, module resolution), not Turbopack-specific code. The issue title mentioning Turbopack may cause people to think switching to webpack is a workaround — it is not.

    3. Route count is the trigger, not config complexity

    Test case Routes Config Result
    Minimal app (1 page, no config) 1 Bare ✅ Loads fine
    Full config, 1 page route 1 Full (259 transpilePackages, all experimental flags) ✅ Loads fine
    Full app 769 Full ❌ OOM at 4.6GB

    Full next.config.ts (259 transpilePackages, 164 excludes, 53 optimizePackageImports, 18 serverExternalPackages) works perfectly with 1 route. The same config with 769 routes triggers OOM.

    4. Node 22 makes the leak lethal (Node 20 survives)

    Node Version IOAccelerator RSS Behavior Outcome
    v22.22.2 4,634 MB RSS tracks IOAccelerator tightly OOM killed at ~45s
    v20.20.2 5,200 MB RSS oscillates 1.7-2.4 GB Survives 67s+

    Same IOAccelerator leak in both versions, but Node 20 pages it to disk while Node 22 maps it as resident. The leak is the same; Node 22 just makes it fatal sooner on constrained machines.

    5. Memory category isolation

    Via footprint command at 4GB RSS:

    Category Size Growing?
    IOAccelerator (dirty) 4,634 MB Only growing category
    MALLOC (all zones) 74 MB Flat
    V8 heap (tag 16) 68 MB Flat
    Stack 1.5 MB Flat
    __TEXT 81 MB Flat

    V8 profiling tools, --max-old-space-size, and native heap profilers are all blind to this — the leak is entirely in IOAccelerator.

    6. Growth pattern is consistent

    Phase 1: Idle          0-15s    ~440MB RSS    Server ready
    Phase 2: Initial load  15-20s   ~1100MB RSS   Page request triggers compilation
    Phase 3: Plateau       20-45s   ~1100MB RSS   Compilation ongoing, stable
    Phase 4: Explosion     45-50s   1100→4000MB   Unbounded growth, 2-4 seconds
    Phase 5: Death         50s+     OOM killed
    

    The Phase 3→4 transition at ~45s is the critical event. Something completes or triggers after ~25s of compilation that causes unbounded IOAccelerator allocation.

    Hypothesis

    CoreServices file operations on Apple Silicon M4 allocate IOAccelerator (GPU-accessible unified memory) for internal buffers. During route discovery/compilation, Next.js performs 43,000+ file stat/watch operations. These buffers accumulate without being freed. next-swc.darwin-arm64.node links CoreFoundation + CoreServices (which handle file I/O on macOS) but does NOT link Metal or IOKit directly — IOAccelerator allocation must come through a transitive path via CoreServices.

    Impact — Total Blocker

    This is a completely blocking issue for us. No page route compiles on the 16GB M4 Mac Mini — zero. Not a slow build, not degraded performance — the dev server is entirely unusable for page development. API routes work, next build completes in 79 seconds, production deploys fine. Only next dev with page routes is broken.

    We've been unable to do any frontend page development on this machine for days. The only workaround we've found is a "bench" tool we built that renames route directories with _ prefix (Next.js private folder convention) to reduce the active route count below ~200, but this means 73% of our routes are inaccessible during development.

    This will affect any team running a monorepo with 200+ page routes on a 16GB Apple Silicon Mac — which is the most common developer machine Apple sells.

    Tooling

    We built a memory watchdog that auto-polls RSS, captures vmmap/footprint at 1GB/2GB/3GB thresholds, and auto-kills at 4GB. Happy to share artifacts from 4 captured runs across Next.js 15.5-16.2.

  5. lukesandberg commented on Apr 12, 2026

    @lukesandberg
    Contributor

    This IOAccelerator memory is just memory allocated by the native binary (which is why it is not visible to node.js tools). As we compile routes we cache information about those routes in memory which is why memory goes up as more routes.

    | Just loading the SWC binary — before compiling anything — allocates 136 MB and reserves 896 MB more.

    yeah this is expected, this is approximately how big the binary is and then we also initialize the native heap

    (also, the turbopackMemoryLimit feature is indeed unimplemented and will likely be removed in a future release)

    Since the concern is about the oomkiller, tracking memory via vmmap is somewhat misleading. When processes map files into ram they get accounted to vmmap but not necessarily to 'physical heap' which is the thing the OOM killer cares about.

    The better metric to track is RSS or Physical Footprint

    vmmap -summary $(pgrep -f next-server) | grep "Physical footprint"

    or just RSS as reported by ps

    ps -o pid,rss,vsz -p $(pgrep -f next-server)

    Since that is what the OOM killer cares about

    From that i can see that RSS does go down over time, in my case it is due to heap compression and swapping

    So killing the server at 4G of allocated IOAccellerator pages is the problem, in all scenarios i see that number only going up over the course of dev server sessions. (this is the behavior of our memory allocator which maps anonymous memory and tags it as droppable instead of returning it) But this isn't the important number, systems have lots of virtual memory address space and you shouldn't care about it. So your watchdog should only care about RSS/Physical footprint (aka working set memory)

    That being said I am are currently working on a few solutions to decrease our 'working set size' in conjunction with our filesystem caching solution.

  6. isaacwasserman commented on Apr 12, 2026

    @isaacwasserman
    Author

    The RSS is misleading as well. These numbers are simply heuristics. The real problem is memory pressure; after compiling a single page on the dev server, MacOS activity monitor claims that next is using >12GB of memory. There's no way that's intentional.

  7. added
    linear: turbopack
    on Apr 20, 2026
  8. mketiku commented on May 23, 2026

    @mketiku

    Additional reproduction — Next.js 16.2.6, Apple Silicon, 128 routes

    Environment

    OS macOS Darwin 25.3.0, Apple Silicon (ARM64)
    RAM 16 GB
    Node.js 24.15.0
    Next.js 16.2.6 (Turbopack default, no flags)
    React 19.2.6
    Package manager Bun
    Router App Router
    Routes 72 page.tsx + 56 route.ts = 128 total
    Key deps @sentry/nextjs 10.52.0, @supabase/supabase-js 2.105.3, posthog-js 1.372.10

    Observed behaviour

    After a normal dev session (~100–200 page compilations via HMR), next-server reaches 9.04 GB RSS in Activity Monitor. Memory grows monotonically and does not reclaim between page navigations or during idle periods.

    V8 vs native breakdown

    To isolate how much of this is V8 vs native, I took a heap snapshot via kill -USR1 <pid> and the Chrome DevTools Protocol:

    • Snapshot file size: 1.25 GB
    • Top 50 retained objects (by self size): 1.66 GB
    • ~7.3 GB invisible to V8 — absent from process.memoryUsage() and not captured in the snapshot

    Running vmmap <pid> | grep "^IOAccelerator" confirms the gap is IOAccelerator allocations, consistent with this report.

    Confirmed non-fixes

    • NODE_OPTIONS=--max-old-space-size=4096 — no effect on the balloon
    • experimental.turbopackMemoryLimit — accepted by config, produces no observable change (as noted in the original report — not wired to the native binary)

    Scale correlation

    The 128-route count fits the pattern reported here (3.5 GB for 5 pages, 13.9 GB for 27 pages) — larger apps hit the ceiling faster. On a 16 GB machine this competes directly with Docker, Chrome, and other dev tooling, quickly pushing into swap.

    The only mitigation found is periodic next dev restarts. Happy to provide additional heap data or run specific diagnostics if useful.

  9. joeyorlando commented on Jun 11, 2026

    @joeyorlando

    @lukesandberg is there any fix planned for this in the next version? 🙏

    without this it basically makes next.js local development unusable on Apple Silicon (insanely slow / eats up all resources on an M5 Macbook Pro) 🙁

  10. lukesandberg commented on Jun 11, 2026

    @lukesandberg
    Contributor

    @joeyorlando The most recent next canary releases have a new feature enabled turbopackMemoryEviction which should help by offloading data to disk when idle. This is still under development but should be a win for your test scenario.

  11. ljrahn commented on Jun 17, 2026

    @ljrahn

    16.3.0-preview.3 very much helped free up memory on my apple silicon. i was completely unable to develop on my 16gb machine before because next was taking +10gb and when im running with docker, my laptop just completely freezes up. with this, next is stable around ~1.5-2gb, and doesnt keep growing.

  12. serban4 commented on Jul 20, 2026

    @serban4

    Additional data point: 52 GB phys_footprint (peak 58 GB) after a ~13 h dev
    session — Next.js 16.2.6, Apple Silicon

    Adding this because it is substantially larger than the numbers reported so
    far and suggests growth is effectively unbounded with session length rather
    than only scaling with route count (~105 routes here, similar to earlier
    reports that saw ~12 GB).

    Environment

    • Next.js 16.2.6, Turbopack (next dev --turbopack), pnpm
    • App Router, ~105 routes (103 pages + 2 API routes)
    • Node.js 26.4.0 (Homebrew), macOS (Darwin 25.5.0), Apple Silicon, 128 GB unified memory
    • next dev ran ~13 h with an AI coding agent driving many incremental
      rebuilds (147 min cumulative CPU on next-server)

    Measurements

    $ footprint <pid>
      Dirty      Clean  Reclaimable    Regions    Category
      52 GB        0 B       784 KB        686    IOAccelerator
     249 MB        0 B          0 B        850    app-specific tag 16
     ...
    phys_footprint: 52 GB
    phys_footprint_peak: 58 GB
    
    $ vmmap --summary <pid>
    Physical footprint:         52.3G   (peak 57.5G)
    Writable regions: written=52.3G(86%)  resident=201.0M(0%)  swapped_out=52.1G(85%)
    IOAccelerator   59.8G virtual   145.4M dirty-resident   51.8G swapped   683 regions
    

    Details consistent with @lukesandberg's explanation (native-binary
    allocations, not actual GPU work):

    • No AGX driver loaded; a 3 s sample shows zero active Metal/IOAccelerator
      stack frames — Metal frameworks are only transitively loaded.
    • Only native addon in the process: next-swc.darwin-arm64.node.
    • ps RSS showed ~2 GB while the real footprint was 52 GB (26×
      underestimate) — nearly all of it compressed/swapped, so it silently
      exhausted swap and the system-wide compressor before anyone noticed.
    • The memory disappears with the process; control long-running Node
      processes on the same machine sit at ~75 MB footprint.

    Haven't tested turbopackMemoryEviction from the 16.3 canaries in this
    project yet — will report back once it reaches stable. Happy to provide more
    diagnostics if useful.

  13. flexi767 commented on Aug 9, 2026

    @flexi767

    Independent confirmation on the current 16.2 stable line, plus a controlled production-mode comparison.

    Environment

    • Apple M5 Max, macOS/Darwin 27.0.0 arm64
    • Node.js 26.4.0
    • Next.js 16.2.11
    • App Router, 106 page.tsx + 335 route.ts source entries

    Real application

    • A freshly restarted next dev process reached 9.8 GB physical footprint after compiling the locale root.
    • The previous long-lived process reached 17.6 GB. Its memory map was dominated by IOAccelerator plus app-specific tag 16.
    • ps RSS was much smaller than footprint, consistent with the compressed/swapped behavior discussed above.
    • A full production build served by next start measured 248 MB footprint after an HTTP 200 render of the same application.
    • Node 24 vs 26 and Turbopack vs webpack controls did not provide a practical dev-mode workaround. --max-old-space-size cannot constrain this native allocation.

    Minimal one-page control

    A temporary one-page, force-dynamic App Router app using the same installed Next/React packages was driven with bounded HTTP requests and sampled using macOS footprint:

    Mode After initial render After 100 requests
    next dev 575 MB 695 MB
    next start 57 MB 92 MB

    This also confirms that the application database, image pipeline, and route code are not required for the dev/production gap, while route count and session length amplify it substantially.

    Our operational mitigation is now: production-mode server for browser QA, serialize browser suites across worktrees, stop idle worktree servers, and restart managed dev servers at a physical-footprint threshold. The full app's production-mode result is stable in the hundreds of MB; production deployments are not showing the dev-server growth.

    I have not yet tested turbopackMemoryEviction on 16.3 preview/canary.

  14. marcoshernanz commented on Aug 31, 2026

    @marcoshernanz
    Contributor

    Thanks for the detailed repro. Turbopack memory eviction shipped in Next.js 16.3 and is enabled by default. Reports here and in #81161 show the working set now settles instead of growing without bound, so I’m closing this as fixed. If high physical footprint still reproduces on the latest 16.3 release, please open a new issue with fresh footprint output and a minimal repro.

  15. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    This issue was closed by a maintainer. If you think it was closed by mistake, you can request that it be reopened within the next 14 days.

    Reply with Reopen: <reason> and explain why the issue is still relevant. If you opened this issue or commented before it was closed, the issue will be reopened automatically.

    After 14 days, please open a new issue with up-to-date details and a reproduction, when applicable.

  16. github-actions commented on Sep 15, 2026

    @github-actions
    Contributor

    This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

  17. locked as resolved and limited conversation to collaborators on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PerformanceSWCTurbopacklinear: turbopacklocked

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions