Try to fix memory leaks by clear OT server before disconnect note

This commit is contained in:
Wu Cheng-Han 2016-10-10 21:05:49 +08:00
parent 138aa876f4
commit b734eb9c85
1 changed files with 3 additions and 0 deletions

View File

@ -543,6 +543,9 @@ function disconnect(socket) {
if (note.server.isDirty) {
updateNote(note, function (err, _note) {
if (err) return logger.error('disconnect note failed: ' + err);
// clear server before delete to avoid memory leaks
note.server.document = "";
note.server.operations = [];
delete note.server;
delete notes[noteId];
if (config.debug) {