You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/npm-packages/ruby-head-wasm-wasi/README.md
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,34 @@ See [the example project](https://github.com/ruby/ruby.wasm/tree/main/packages/n
85
85
</html>
86
86
```
87
87
88
+
89
+
## GC limitation with JavaScript interoperability
90
+
91
+
Since JavaScript's GC system and Ruby's GC system are separated and not cooperative, they cannot collect cyclic references between JavaScript and Ruby objects.
92
+
93
+
The following code will cause a memory leak:
94
+
95
+
```javascript
96
+
classJNode {
97
+
setRNode(rnode) {
98
+
this.rnode= rnode;
99
+
}
100
+
}
101
+
jnode =newJNode();
102
+
103
+
rnode =vm.eval(`
104
+
class RNode
105
+
def set_jnode(jnode)
106
+
@jnode = jnode
107
+
end
108
+
end
109
+
RNode.new
110
+
`)
111
+
112
+
rnode.call("set_jnode", vm.wrap(jnode))
113
+
jnode.setRNode(rnode);
114
+
```
115
+
88
116
<!-- The APIs section was generated by `npx documentation readme ./dist/index.esm.js --section=APIs` -->
0 commit comments