From 3b6ab9e820a8a237873412c6886dbe2618537df0 Mon Sep 17 00:00:00 2001 From: Jonas Dohse Date: Sun, 17 May 2015 18:57:42 +0000 Subject: [PATCH] Allow garbage collection of processed queue items Set processed queue items to `null` to allow garbage collection of these items. The command queue contains callbacks. They contain the stack of the current fiber, which can be large. Allow earlier garbage collection of these stacks by removing the reference to the queue items. --- lib/queue.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/queue.js b/lib/queue.js index 3fc87ab..ece2e6b 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -18,7 +18,10 @@ Queue.prototype.shift = function () { return; } } - return this.head[this.offset++]; // sorry, JSLint + var item = this.head[this.offset]; + this.head[this.offset] = null; + this.offset++; + return item; }; Queue.prototype.push = function (item) {