Skip to content
This repository

IE Leak: Array.flatten #2175

Closed
ibolmo opened this Issue December 19, 2011 · 0 comments

1 participant

Olmo Maldonado
Olmo Maldonado
Owner

As per: #2127 (comment)

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;
        };
    }
Olmo Maldonado ibolmo closed this January 29, 2012
Olmo Maldonado ibolmo reopened this January 29, 2012
Olmo Maldonado ibolmo referenced this issue from a commit January 29, 2012
Commit has since been removed from the repository and is no longer available.
Olmo Maldonado ibolmo referenced this issue January 29, 2012
Merged

Fixes #2175 #2264

Olmo Maldonado ibolmo referenced this issue from a commit in ibolmo/mootools-core January 29, 2012
Olmo Maldonado Fixes #2175
This adds an additional check to `instanceOf` that prevents extraneous
instanceof checks for non-objects (e.g. window) as per:
http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak

PASSES: IE6-9; FFx 3-5, 8, 10; Chrome latest; Safari 5; Opera 11
4613cae
Olmo Maldonado ibolmo closed this in 5223508 February 07, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.