Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE Leak: Array.flatten #2175

Closed
ibolmo opened this issue Dec 19, 2011 · 0 comments
Closed

IE Leak: Array.flatten #2175

ibolmo opened this issue Dec 19, 2011 · 0 comments
Milestone

Comments

@ibolmo
Copy link
Member

ibolmo commented Dec 19, 2011

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;
        };
    }
@ibolmo ibolmo closed this as completed Jan 30, 2012
@ibolmo ibolmo reopened this Jan 30, 2012
@ibolmo ibolmo mentioned this issue Jan 30, 2012
ibolmo added a commit to ibolmo/mootools-core that referenced this issue Feb 5, 2012
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
@ibolmo ibolmo closed this as completed in 5223508 Feb 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant