From 86bee39b5172520a0ce3328e88de4bf290f04c7c Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Thu, 25 Sep 2014 18:32:01 +0200 Subject: [PATCH] update Ox.GarbageCollection: use .collect to collect; don't run immediately --- source/Ox.UI/js/Core/GarbageCollection.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/source/Ox.UI/js/Core/GarbageCollection.js b/source/Ox.UI/js/Core/GarbageCollection.js index 4d0cff06..524264d0 100644 --- a/source/Ox.UI/js/Core/GarbageCollection.js +++ b/source/Ox.UI/js/Core/GarbageCollection.js @@ -8,14 +8,10 @@ Ox.GarbageCollection GarbageCollection Ox.GarbageCollection = (function() { - var that = function() { - collect(); - }, + var that = {}, timeout; - collect(); - - function collect() { + that.collect = function() { var len = Ox.len(Ox.elements); Object.keys(Ox.elements).forEach(function(id) { var $element = Ox.elements[id]; @@ -25,9 +21,9 @@ Ox.GarbageCollection = (function() { } }); timeout && clearTimeout(timeout); - timeout = setTimeout(collect, 60000); + timeout = setTimeout(that.collect, 60000); Ox.Log('GC', len, '-->', Ox.len(Ox.elements)); - } + }; /*@ debug debug info @@ -41,7 +37,7 @@ Ox.GarbageCollection = (function() { }); Ox.forEach(classNames, function(count, className) { sorted.push({className: className, count: count}); - }) + }); return sorted.sort(function(a, b) { return a.count - b.count; }).map(function(v) { @@ -49,6 +45,8 @@ Ox.GarbageCollection = (function() { }).join('\n'); }; + setTimeout(that.collect, 60000); + return that; }());