Skip to content

Destroy outdated yDocs, ensure persisted doc has loaded#7

Open
micrology wants to merge 1 commit intoyjs:mainfrom
micrology:manage-memory
Open

Destroy outdated yDocs, ensure persisted doc has loaded#7
micrology wants to merge 1 commit intoyjs:mainfrom
micrology:manage-memory

Conversation

@micrology
Copy link

I had trouble with memory management using y-websocket-server. The server process was using several GBs of RAM. I found that this was because the server was retaining yDocs in memory, even after the client had closed the connection. Secondly, when using LevelDB as a persistence database, the server was sending a sync message before LevelDB had supplied the document, with the result that empty documents were being served to clients.

This PR (a) includes code that is very careful to destroy YDocs when they are no longer needed (b) allows optional monitoring of memory use (set the environment variable VERBOSE non-zero to log connections and memory use to the console) and (c) awaits the loading of a persisted document before emitting the sync signal (the last relates to event when documents have synced).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant