Skip to content

Garbage Collection (WasmGC)

WasmGC provides reference-typed objects (structs, arrays) that engines can manage with garbage collection. This enables efficient runtimes for languages like Kotlin, Java, and Dart.

Key concepts:

  • Reference-typed heaps managed by the VM.
  • Typed struct and array values.
  • Interop with host via externref.

Syntax and support are still evolving — check your toolchain’s documentation for exact WAT forms.

  • GC Typessub, final, rec, field, struct, array
  • GC Structstruct.new, struct.get, struct.set
  • GC Arrayarray.new, array.get, array.set, array.len
  • GC i31ref.i31, i31.get_s, i31.get_u
  • GC Castsref.test, ref.cast, br_on_cast