Skip to content

Commit b5276c9

Browse files
committed
Address review comments
1 parent ca80905 commit b5276c9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/content/changelog/workers/2025-05-08-finalization-registry.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Improved Memory Efficiency for WebAssembly Workers
2+
title: Improved memory efficiency for WebAssembly Workers
33
description: With the introduction of FinalizationRegistry in Workers Runtime, toolchains like Emscripten and wasm-bindgen can automatically reclaim unused WebAssembly heap and reduce memory leaks.
44
products:
55
- workers
@@ -10,4 +10,4 @@ date: 2025-05-08T00:00:00Z
1010

1111
This can reduce memory leaks when using WebAssembly-based Workers, which includes [Python Workers](/workers/languages/python/) and [Rust Workers](/workers/languages/rust/). The FinalizationRegistry works by enabling toolchains such as [Emscripten](https://emscripten.org/) and [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/) to automatically free WebAssembly heap allocations. If you are using WASM and seeing Exceeded Memory errors and cannot determine a cause using [memory profiling](/workers/observability/dev-tools/memory-usage/), you may want to enable the FinalizationRegistry.
1212

13-
For more information see the [`enable_weak_ref`](/workers/configuration/compatibility-flags/#enable-finalizationregistry-and-weakref) compatibility flag documentation.
13+
For more information refer to the [`enable_weak_ref`](/workers/configuration/compatibility-flags/#enable-finalizationregistry-and-weakref) compatibility flag documentation.

src/content/compatibility-flags/js-weak-refs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ disable_flag: "disable_weak_ref"
1212
---
1313

1414
Enables the use of [`FinalizationRegistry`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry) and [`WeakRef`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef) built-ins.
15-
* `FinalizationRegistry` allows you to register a cleanup callback that runs after an object has been garbage-collected.
16-
* `WeakRef` creates a weak reference to an object, allowing it to be garbage-collected if no other strong references exist.
15+
- `FinalizationRegistry` allows you to register a cleanup callback that runs after an object has been garbage-collected.
16+
- `WeakRef` creates a weak reference to an object, allowing it to be garbage-collected if no other strong references exist.
1717

1818
:::note[Behaviour]
19-
`FinalizationRegistry` cleanup callbacks may execute at any point during your request lifecycle, even after your invoked handler has completed (similar to `ctx.waitUntil()`). These callbacks do not have an associated async context — you cannot perform any I/O within them, including emitting events to a tail Worker.
19+
`FinalizationRegistry` cleanup callbacks may execute at any point during your request lifecycle, even after your invoked handler has completed (similar to `ctx.waitUntil()`). These callbacks do not have an associated async context. You cannot perform any I/O within them, including emitting events to a tail Worker.
2020
:::
2121

2222
:::caution
23-
These APIs are fundamentally non-deterministic — the timing and execution of garbage collection are unpredictable, and you **should not rely on them for essential program logic**. Additionally, cleanup callbacks registered with `FinalizationRegistry` may **never be executed**, including but not limited to cases where garbage collection is not triggered, or your Worker gets evicted.
23+
These APIs are fundamentally non-deterministic. The timing and execution of garbage collection are unpredictable, and you **should not rely on them for essential program logic**. Additionally, cleanup callbacks registered with `FinalizationRegistry` may **never be executed**, including but not limited to cases where garbage collection is not triggered, or your Worker gets evicted.
2424
:::

0 commit comments

Comments
 (0)