yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
492 stars 255 forks source link

Memory leaks in yjs websocket docs map #145

Open sbavoma opened 1 year ago

sbavoma commented 1 year ago

I did some profiling on our yjs websocket server and found that there is a memory leak present in there. Even after the yjs ws session has ended, the library fails to de-reference its Yjs Doc objects leading them to pile up in memory.

After careful debugging I have found that here is the issue - https://github.com/yjs/y-websocket/blob/master/bin/utils.js#L66 Perhaps we should use a weakmap? Is there any way to make sure when we call delete on this map we destroy all references.

jiangxiaoqiang commented 12 months ago

I am facing the same issue.