summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2012-07-12 15:40:45 -0700
committerNathan Rajlich <nathan@tootallnate.net>2012-07-12 15:43:35 -0700
commit713b9249e1e7cbc028e7e4f29ef7dd6a68e03375 (patch)
tree38a50298913e559ae4e7a1b4224ad40194975156 /lib
parent3a6314dbe159c40aa4cd95786bf55f6dcd0580bb (diff)
downloadnodejs-713b9249e1e7cbc028e7e4f29ef7dd6a68e03375.tar.gz
nodejs-713b9249e1e7cbc028e7e4f29ef7dd6a68e03375.tar.bz2
nodejs-713b9249e1e7cbc028e7e4f29ef7dd6a68e03375.zip
Revert "events: don't delete the listeners array in removeListener()"
This reverts commit 928ea564d16da47e615ddac627e0b4d4a40d8196. Keeping the original Array instance in-place essentially causes a memory leak on EventEmitters that use an infinite number of event names (an incrementing counter, for example), which isn't an unreasonable thing to want to do. Fixes #3702.
Diffstat (limited to 'lib')
-rw-r--r--lib/events.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/events.js b/lib/events.js
index 7e219a14a..c2b604f89 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -214,6 +214,8 @@ EventEmitter.prototype.removeListener = function(type, listener) {
if (position < 0) return this;
list.splice(position, 1);
+ if (list.length == 0)
+ delete this._events[type];
} else if (list === listener ||
(list.listener && list.listener === listener))
{