safeWithZoneArena<R> method

R safeWithZoneArena<R>(
  1. R computation(), [
  2. Allocator? allocator
])

Safely runs the provided computation function within a zoned Arena, ensuring that all allocations are released upon completion.

If allocator is provided, it is used for allocations; otherwise, the default allocator from the library is used.

This method is useful when multiple wasm modules are loaded and it ensures that the library-specific allocator is used.

Returns the result of the computation.

Implementation

R safeWithZoneArena<R>(R Function() computation, [Allocator? allocator]) {
  return withZoneArena(computation, allocator ?? _library.allocator);
}