Skip to content

Turbopack dev: 6-8GB RSS on Apple Silicon caused by Wasmer/Cranelift JIT (IOAccelerator MAP_JIT pages) #91585

Closed

Description

@icex

Link to the code that reproduces this issue

Any Next.js 16.x project with Turbopack (default bundler) on Apple Silicon macOS.

To Reproduce

  1. npx next dev on any non-trivial Next.js 16 project on Apple Silicon
  2. Open 2-3 pages in the browser
  3. Check RSS with ps aux | grep next-server

Current vs. Expected behavior

Current: next-server process consumes 6-8GB RSS after compiling a few pages. On 8GB machines this causes OOM.

Expected: A dev bundler should not exceed 1-2GB RSS.

Provide environment information

- Next.js: 16.1.7
- Node.js: v22.21.1 / v20.19.0 (same behavior)
- macOS: Darwin 25.3.0 (Apple Silicon M1 Max, 36GB RAM)
- @next/swc-darwin-arm64: 16.1.7

Root Cause Analysis

The 6-8GB is NOT V8 heap — it's IOAccelerator (MAP_JIT) pages

Using vmmap to analyze the next-server process after compiling 2 pages:

Region Type                  Resident MB  (regions)
IOAccelerator                      6130      (139)    ← THIS IS THE PROBLEM
mapped file                         345       (80)
__TEXT                               300      (426)
Memory Tag 255 (Rust/mimalloc)       296     (1209)
__OBJC_RO                             60        (1)
MALLOC_SMALL                          50       (25)

V8's JS heap is only ~300MB (process.memoryUsage().heapUsed). The 6.1GB is in IOAccelerator regions — macOS's label for MAP_JIT mmap pages on Apple Silicon.

IOAccelerator growth correlates with page compilation

State RSS IOAccelerator regions
SWC binary loaded (no compilation) 49 MB 66 (1.4 MB total)
After compiling / 2,600 MB 97
After compiling / + /pay 3,800 MB 104
After browsing 5+ pages 6,900 MB 141

Each compiled page adds ~7 IOAccelerator regions that grow from 16KB to 64-128MB each (all rw-/rwx SM=PRV).

Source: Wasmer + Cranelift JIT compiled into SWC binary

The next-swc.darwin-arm64.node binary (100MB) statically links:

  • Wasmer 6.1.0-rc3 (337 string references in binary)
  • Cranelift code generator (178 references)
  • wasmer-compiler-cranelift-6.1.0-rc.3
  • swc_plugin_runner-23.0.0

When Turbopack compiles modules, Cranelift JIT-compiles code into MAP_JIT pages. On Apple Silicon, these pages are labeled IOAccelerator by macOS and grow without bound.

experimental.turbopackMemoryLimit is accepted but NEVER used

In crates/next-napi-bindings/src/next_api/turbopack_ctx.rs:

pub fn create_turbo_tasks(
    output_path: PathBuf,
    persistent_caching: bool,
    _memory_limit: usize,       // ← PREFIXED WITH UNDERSCORE = UNUSED
    dependency_tracking: bool,
    is_ci: bool,
    is_short_session: bool,
) -> Result<NextTurboTasks> {
    // _memory_limit is never referenced in the function body

The parameter is passed from JS config but silently ignored. BackendOptions has no memory limit field either.

What we tried (none helped with IOAccelerator)

Approach Result
--max-old-space-size=1024 Only limits V8 heap (300MB), no effect on IOAccelerator
Disable V8 JIT (--no-sparkplug --no-turbofan) No change — IOAccelerator is from Cranelift, not V8
MIMALLOC_PURGE_DELAY=0 Only affects Memory Tag 255 (mimalloc), not IOAccelerator
RAYON_NUM_THREADS=1 No change
turbopackMemoryLimit: 2GB Accepted in config output but ignored (see above)
turbopackFileSystemCacheForDev: true Helps on restart (2.6GB vs 6.8GB cold) but grows back as pages are visited

Suggested fixes

  1. Implement the _memory_limit parameter — it's already wired through from JS config but unused in Rust
  2. Lazy-initialize Wasmer/Cranelift — don't allocate JIT pools unless SWC WASM plugins are actually configured
  3. Use Singlepass compiler instead of Cranelift for dev mode — single-pass compilation uses dramatically less memory
  4. Free Cranelift JIT pages after compilation is complete — the compiled WASM code doesn't need to persist in executable memory after the transform is done
  5. Cap IOAccelerator/MAP_JIT pool size — Cranelift should have a configurable limit on JIT code cache

Which area(s) are affected?

  • Turbopack
  • Memory usage
  • Developer experience on constrained hardware

Which stage(s) are affected?

  • next dev (Turbopack)

Additional context

The turbopackFileSystemCacheForDev: true experimental flag significantly helps with restart memory (avoids cold recompilation), but doesn't prevent growth during a session as new pages are visited. It should be the default for dev.

This issue affects all Apple Silicon Macs but is most critical on 8GB machines where the 6-8GB RSS causes system OOM. The same IOAccelerator pattern likely occurs on other ARM64 platforms.

Activity

  1. added
    invalid link
    on Mar 18, 2026
  2. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    We could not detect a valid reproduction link. Make sure to follow the bug report template carefully.

    Why was this issue closed?

    To be able to investigate, we need access to a reproduction to identify what triggered the issue. We need a link to a public GitHub repository (template for App Router, template for Pages Router), but you can also use these templates: CodeSandbox: App Router or CodeSandbox: Pages Router.

    The bug template that you filled out has a section called "Link to the code that reproduces this issue", which is where you should provide the link to the reproduction.

    • If you did not provide a link or the link you provided is not valid, we will close the issue.
    • If you provide a link to a private repository, we will close the issue.
    • If you provide a link to a repository but not in the correct section, we will close the issue.

    What should I do?

    Depending on the reason the issue was closed, you can do the following:

    • If you did not provide a link, please open a new issue with a link to a reproduction.
    • If you provided a link to a private repository, please open a new issue with a link to a public repository.
    • If you provided a link to a repository but not in the correct section, please open a new issue with a link to a reproduction in the correct section.

    In general, assume that we should not go through a lengthy onboarding process at your company code only to be able to verify an issue.

    My repository is private and cannot make it public

    In most cases, a private repo will not be a sufficient minimal reproduction, as this codebase might contain a lot of unrelated parts that would make our investigation take longer. Please do not make it public. Instead, create a new repository using the templates above, adding the relevant code to reproduce the issue. Common things to look out for:

    • Remove any code that is not related to the issue. (pages, API routes, components, etc.)
    • Remove any dependencies that are not related to the issue.
    • Remove any third-party service that would require us to sign up for an account to reproduce the issue.
    • Remove any environment variables that are not related to the issue.
    • Remove private packages that we do not have access to.
    • If the issue is not related to a monorepo specifically, try to reproduce the issue without a complex monorepo setup

    I did not open this issue, but it is relevant to me, what can I do to help?

    Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps by opening a new issue.

    I think my reproduction is good enough, why aren't you looking into it quickly?

    We look into every Next.js issue and constantly monitor open issues for new comments.

    However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

    Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

    Useful Resources

  3. locked and limited conversation to collaborators on Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalid link

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions