forked from 0x2620/oxjs
remove unneeded Ox. prefix from path and file names
This commit is contained in:
parent
4138e4e558
commit
51696562f1
1365 changed files with 43 additions and 43 deletions
52
source/UI/js/Core/GarbageCollection.js
Normal file
52
source/UI/js/Core/GarbageCollection.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.GarbageCollection <f> GarbageCollection
|
||||
() -> <o> run garbage collection
|
||||
debug() -> {} output debug information
|
||||
@*/
|
||||
|
||||
Ox.GarbageCollection = (function() {
|
||||
|
||||
var that = {},
|
||||
timeout;
|
||||
|
||||
that.collect = function() {
|
||||
var len = Ox.len(Ox.$elements);
|
||||
Object.keys(Ox.$elements).forEach(function(id) {
|
||||
var $element = Ox.$elements[id];
|
||||
if ($element && Ox.isUndefined($element.data('oxid'))) {
|
||||
$element.remove();
|
||||
delete Ox.$elements[id];
|
||||
}
|
||||
});
|
||||
timeout && clearTimeout(timeout);
|
||||
timeout = setTimeout(that.collect, 60000);
|
||||
Ox.Log('GC', len, '-->', Ox.len(Ox.$elements));
|
||||
};
|
||||
|
||||
/*@
|
||||
debug <f> debug info
|
||||
() -> <s>
|
||||
@*/
|
||||
that.debug = function() {
|
||||
var classNames = {}, sorted = [];
|
||||
Ox.forEach(Ox.$elements, function($element, id) {
|
||||
var className = $element[0].className;
|
||||
classNames[className] = (classNames[className] || 0) + 1;
|
||||
});
|
||||
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) {
|
||||
return v.count + ' ' + v.className
|
||||
}).join('\n');
|
||||
};
|
||||
|
||||
setTimeout(that.collect, 60000);
|
||||
|
||||
return that;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue