mootools/mootools-core — Issue #2175: IE Leak: Array.flatten
Author: ibolmo
Created: 2011-12-19 15:04:55+00:00
State: open

As per: https://github.com/mootools/mootools-core/issues/2127#issuecomment-3153415

It appears that the calling of instanceof on 'non-objects' (mootools.js flatten()) causes the memory leaks in IE. http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak

We ended up implementing the following:

if(Browser.ie) {
instanceOf = this.instanceOf = function(item, object) {
if (item == null) return false;
// Avoid calling instanceof on certain "non-objects" to prevent memory leaks in IE
if (!item.hasOwnProperty) return false;
var constructor = item.$constructor || item.constructor;
while (constructor){
if (constructor === object) return true;
constructor = constructor.parent;
}
return item instanceof object;
};
}