yjs / y-websocket

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

Awareness and Doc memory leak #70

Closed nemanja-tosic closed 3 years ago

nemanja-tosic commented 3 years ago

Describe the bug

The beforeunload listener isn't removed on destroy, an Awareness instance and a Doc instance are captured via closure and cannot be garbage collected in the browser. See: https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js#L280

To Reproduce

  1. Instantiate provider
  2. Destroy it
  3. Make a memory snapshot and look for retainers of Awareness/Doc

Expected behavior

Awareness/Doc should be garbage collected after destroying the provider.

Environment Information

Additional

Memory profile after destroying the provider.