Skip to content
Snippets Groups Projects
Commit 3dcabb84 authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) force gc yjs room on destruct

parent 6c428395
Branches
No related tags found
1 merge request!71Rust WASM CRDT implementation
Pipeline #108921 canceled
......@@ -19,7 +19,7 @@
"test": "jest --testPathIgnorePatterns src/liowebrtc src/rtcpeerconnection src/signalbuddy src/yjs src/drawing-crdt",
"test-changed": "jest --only-changed --testPathIgnorePatterns src/liowebrtc src/rtcpeerconnection src/signalbuddy src/yjs src/drawing-crdt",
"test-coverage": "jest --coverage --testPathIgnorePatterns src/liowebrtc src/rtcpeerconnection src/signalbuddy src/yjs src/drawing-crdt",
"benchmarks": "node --experimental-modules __benchmarks__/puppeteer.js | npx tap-summary",
"benchmarks": "node --experimental-modules __benchmarks__/puppeteer.js | npx tap-summary --no-progress",
"test-e2e:peer1": "testcafe chrome:headless __e2e_tests__/peer1.e2e.js",
"test-e2e:peer2": "testcafe chrome:headless __e2e_tests__/peer2.e2e.js",
"test-e2e": "run-p test-e2e:*",
......
......@@ -13,6 +13,29 @@ yUnion(Y)
yMap(Y)
yArray(Y)
function gc(obj) {
const objs = new Set()
const free = (obj) => {
if (obj == null) return
for (const key of Object.keys(obj)) {
if (typeof obj[key] == "object") {
if (!objs.has(obj[key])) {
objs.add(obj[key])
free(obj[key])
}
}
delete obj[key]
}
}
free(obj)
objs.clear()
}
export default class YjsCRDTWrapper extends Y.AbstractConnector {
constructor(y, options) {
if (options === undefined) {
......@@ -92,10 +115,9 @@ export default class YjsCRDTWrapper extends Y.AbstractConnector {
this.mesh.disconnect()
this.mesh = null
this.y.destroy()
this.y = null
delete this.room
this.room = null
gc(this)
}
static async initialise(room, options) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment