Skip to content

compute.CPUndarray#destroy

Summary

compute.CPUndarray#destroy deterministically releases the ndarray's WebAssembly backing bytes and its shape, stride, and indexing allocations. The call is idempotent.

After destruction, pointer access, data views, indexing, mutation, zeroing, and GPU upload throw. Previously returned typed-array views must no longer be used because their storage has been returned to the Wasm heap.

Syntax

CPUndarray.destroy(): void
a.destroy();

Returns

void

Example

const a = wgpu.compute.CPUndarray.fromArray("f32", [2], [1, 2]);
try {
    console.log(Array.from(a.data()));
} finally {
    a.destroy();
}

See Also