From 84d0664112181608c848b32fabc4f22b1c2c20ff Mon Sep 17 00:00:00 2001 From: Jay Phelps Date: Tue, 5 Nov 2013 18:50:39 -0800 Subject: [PATCH] Fixed memory leak with debounce/throttle arguments and context --- lodash.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lodash.js b/lodash.js index 5b27c02ce..2b2f62348 100644 --- a/lodash.js +++ b/lodash.js @@ -5697,6 +5697,7 @@ if (isCalled) { lastCalled = now(); result = func.apply(thisArg, args); + args = thisArg = null; } } else { timeoutId = setTimeout(delayed, remaining); @@ -5711,6 +5712,7 @@ if (trailing || (maxWait !== wait)) { lastCalled = now(); result = func.apply(thisArg, args); + args = thisArg = null; } }; @@ -5733,6 +5735,7 @@ } lastCalled = stamp; result = func.apply(thisArg, args); + args = thisArg = null; } else if (!maxTimeoutId) { maxTimeoutId = setTimeout(maxDelayed, remaining); @@ -5743,6 +5746,7 @@ } if (leadingCall) { result = func.apply(thisArg, args); + args = thisArg = null; } return result; };