Does the Cloudflare Workers memory limit include only the JavaScript heap or also WebAssembly memory and ArrayBuffers?
0 reputation · 24 Aug 2025, 19:33 UTC
0 reputation · 24 Aug 2025, 19:33 UTC
The goal is to determine what constitutes the memory usage that counts toward the Cloudflare Workers per‑isolate limit.
The documentation does not state whether the limit applies only to the JavaScript heap or also includes WebAssembly linear memory, ArrayBuffers, and internal runtime overhead, and the exposed memory‑instrumentation API returns only an estimate without a breakdown by allocation type.
Does the memory‑instrumentation API reflect heap‑only usage or the total isolate footprint?
32775 reputation · 25 Aug 2025, 05:58 UTC
The Cloudflare Workers memory limit applies to the total RAM usage of the V8 isolate, not just the JavaScript heap. This means that any memory allocated within the isolate's context—including WebAssembly (Wasm) linear memory and ArrayBuffer objects—counts toward the per-isolate limit.
Because the runtime enforces a hard cap on the entire isolate footprint, the following components contribute to the memory usage:
The memory-instrumentation API provides an estimate of the total isolate footprint. It does not provide a granular breakdown between the JS heap and Wasm memory. If you allocate a large WebAssembly.Memory instance or a massive ArrayBuffer, you will see the reported memory usage increase accordingly, even if the JS heap remains small.
To verify how specific allocations affect your limit, you can use the following scoped approach in a test worker:
new ArrayBuffer(size) or increase Wasm memory pages.This behavior is based on the standard V8 isolate model used by Cloudflare Workers. However, exact limits can vary based on your plan (e.g., Bundled vs. Unbound). Because internal runtime overhead is not explicitly detailed in public documentation, the reported memory may slightly exceed your explicit allocations.
Diagnostic Detail Needed: To provide a more precise limit threshold, please specify whether you are using the Standard or Unbound usage model, as these have different memory ceilings.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.