I am using y-websocket 1.5.0 as the server side to do some collaboarate task. Now I found the y-websocket always restart after running for some peroid of time. I tried to dump the memory and found the map with 0 element contains 50000+. It seems the map did not released properly after use.
- When did the map will cause memory leak in node?
- how to properly close the map after use?
I have tried to fix the memory leak map in y-websocket https://github.com/yjs/y-websocket/blob/master/bin/utils.js#L66 like this:
if (doc.conns.size === 0 && persistence !== null) {
// if persisted, we store state and destroy ydocument
persistence.writeState(doc.name, doc).then(() => {
doc.destroy()
})
docs.delete(doc.name)
doc.conns = null
}
it seems break the workflow of y-websocket. what should I do to fixed this problem? there is some issue about this: https://github.com/yjs/y-websocket/issues/145 and https://github.com/yjs/y-websocket/issues/163