summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-10 21:05:49 +0800
committerWu Cheng-Han2016-10-10 21:05:49 +0800
commitb734eb9c85fc6b2cfe534206f0f1b01656d9acc3 (patch)
tree4cc7c71c2942a490abbe207040cf3daac0b0194b /lib
parent138aa876f4fa66dd85a5f3d0fc15ffd76c441022 (diff)
Try to fix memory leaks by clear OT server before disconnect note
Diffstat (limited to 'lib')
-rw-r--r--lib/realtime.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index 0fcd2eaa..ea3735a6 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -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) {