Skip to content

Fatal process out of memory (Zone) during parsing — V8 WASM compilation OOM on Node v24 #298

@a1398394385

Description

@a1398394385

Bug Description

codegraph init -i crashes with Fatal process out of memory: Zone during the parsing phase at ~78%. This is not a system-level OOM — the system has plenty of available memory. The crash is a V8 Zone allocator OOM triggered during WebAssembly compilation.

Environment

  • CodeGraph version: 0.7.9
  • Node.js version: v24.13.0 (via nvm)
  • OS: macOS Darwin 25.5.0 (ARM64, Apple Silicon)
  • Hardware: Mac Mini, Apple M-series (10 CPUs), 32GB RAM
  • Project size: 2,583 files

Memory at Crash Time

  • Total system RAM: 32 GB (34,359,738,368 bytes)
  • Available memory (free + inactive + speculative): ~17 GB (1,125,561 pages × 16KB page size)
  • This is NOT a system OOM — vast memory headroom at the time of the crash.

Stack Trace

The crash trace goes entirely through V8's TurboShaft WASM compilation pipeline:

Fatal process out of memory: Zone

 1: node::NodePlatform::GetStackTracePrinter()
 2: v8::base::FatalOOM()
 3: v8::internal::V8::FatalProcessOutOfMemory()
 4: v8::internal::Zone::Expand()              ← Zone allocator exhausted
...
10: v8::internal::compiler::turboshaft::Pipeline::Run<WasmLoweringPhase>()
11: v8::internal::compiler::Pipeline::GenerateWasmCode()
12: ExecuteTurboshaftWasmCompilation()
13: wasm::WasmCompilationUnit::ExecuteCompilation()
...

The crash is in WasmLoweringReducer → WasmLoweringPhase → GenerateWasmCode → ExecuteTurboshaftWasmCompilation.

Root Cause Analysis

This crash is consistent with Node.js v24's TurboShaft compiler running out of V8 Zone memory when loading tree-sitter WASM grammars. CodeGraph uses tree-sitter for parsing multiple languages (TypeScript, Python, Go, Rust, Java, etc.), and tree-sitter loads its language parsers as WebAssembly modules. V8's Zone allocator has a limited budget for WASM compilation, and when multiple tree-sitter WASM grammars are loaded simultaneously, the Zone is exhausted.

Key observations:

  1. The project has 2,583 files spanning many languages (the config includes 20+ language parsers)
  2. No .wasm files exist in the project itself — the WASM compilation is from tree-sitter's language parsers
  3. The existing .codegraph/codegraph.db was partially built (70.4MB partial index), suggesting parsing gets partway through before the Zone is exhausted
  4. The crash is reproducible — it happens consistently at ~78% parsing

Possible Solutions

  1. Reduce Node.js memory pressure for WASM: Allow configuring --max-old-space-size or similar Node.js flags
  2. Lazy-load tree-sitter parsers: Only compile WASM grammars when needed, not all at once
  3. Limit concurrent WASM compilation: Process files in smaller batches
  4. Document Node.js version compatibility: Node v24's TurboShaft compiler may have a tighter Zone budget than v22 or v20

Workaround Attempted

Cleared .codegraph/ and retried — same reproducible crash at ~78%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions