diff --git a/wfa.js b/wfa.js index ef0abda..d785298 100644 --- a/wfa.js +++ b/wfa.js @@ -300,10 +300,14 @@ // func finalizeRef(v ref) "syscall/js.finalizeRef": (v_ref) => { - // Note: TinyGo does not support finalizers so this should never be - // called. - //console.error('syscall/js.finalizeRef not implemented'); - // for whatever reason this is called by wfajs but doesnt impact the results at all?? + const id = mem().getUint32(unboxValue(v_ref), true); + this._goRefCounts[id]--; + if (this._goRefCounts[id] === 0) { + const v = this._values[id]; + this._values[id] = null; + this._ids.delete(v); + this._idPool.push(id); + } }, // func stringVal(value string) ref