Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE6/7/8 Out of Memory?

I was doing some cross browser testing on certain piece of functionality today, and ran across a rather nifty little gem.

In IE8: Out of memory at line: 99

In IE7: Out of memory at line: 100

In IE6: Stack overflow at line: 101

From what I've been able to dig up, most of the time these messages start appearing, it's an issue with having an array in which the number of elements is greater than 65,535. However, I don't believe that that's the issue at hand here.

The functionality in question is an action from within an iframe "closing" the current iframe and "opening" another using jQuery. It's actually happening on the close/open interaction.

Has anyone seen anything like this before?

Edit: Upon further investigation, it doesn't actually seem to be related to the iframes. Still digging, but any suggestions would be appreciated.

like image 946
Collin Klopfenstein Avatar asked Oct 11 '10 21:10

Collin Klopfenstein


1 Answers

So it turned out to be an issue with IE and everything else handling things differently...as usual.

I have a function that I'm using to throw an error, and it's recursive by design. I wanted the error to be displayed in the main Document, not an iframe (which are being used extensively on this site, unfortunately). The gist of my function is as follows:

myClass.myErrorFunc = function ( msg ) {
    if ( parent !== window ) {
        parent.myClass.myErrorFunc( msg );
    } else {
        // display the error
    }
}

This works GREAT in Chrome and Firefox. It recurses one level and does the error displaying in the main window because once it gets to the top level, the parent is itself. Apparently in IE, however, window's parent is NEVER itself. Thus, infinite recursion.

Stay tuned for a solution.

Edit: Apparently, it was an issue with using !== instead of !=. When I switched it to !=, the second time through (as this is being run from an iframe), window == parent evaluates true, but window === parent does not...

Whatever, I'll take it...

Thanks for your help guys.

like image 120
Collin Klopfenstein Avatar answered Sep 28 '22 08:09

Collin Klopfenstein