简体   繁体   English

IE6 / 7/8内存不足?

[英]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 在IE8中: Out of memory at line: 99

In IE7: Out of memory at line: 100 在IE7中: Out of memory at line: 100

In IE6: Stack overflow at line: 101 在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 . 从我能够挖掘出来的,大多数时候这些消息开始出现,这是一个有一个元素数量大于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. 有问题的功能是iframe一个动作“关闭”当前iframe并使用jQuery“打开”另一个iframe 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. 编辑 :经过进一步调查,它实际上似乎与iframe无关。 Still digging, but any suggestions would be appreciated. 仍在挖掘,但任何建议将不胜感激。

So it turned out to be an issue with IE and everything else handling things differently...as usual. 因此,事实证明,IE和其他所有处理事物的问题都是一个问题......像往常一样。

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). 我希望错误显示在主文档中,而不是iframe(不幸的是,它在本网站上被广泛使用)。 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. 这适用于Chrome和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. 然而,显然在IE中,窗口的父亲永远不会。 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... 当我把它切换到!= ,第二次通过(因为这是从iframe运行), window == parent计算为true,但是window === parent不...

Whatever, I'll take it... 无论如何,我会接受它......

Thanks for your help guys. 谢谢你的帮助。

It would seem that you take too much memory with something and IE does not have so much memory allocated for that kind of something :) Other browsers do. 看起来你花了太多的内存和IE没有那么多的内存分配给那种东西:)其他的浏览器。 If you take a look at those line numbers that you have or debug your code with IE8 developer tools you should get your answer. 如果您查看自己拥有的行号或使用IE8开发人员工具调试代码,您应该得到答案。

If it is not a recursion it may be a loop that keeps eating more memory until it runs out. 如果它不是一个递归,它可能是一个循环,在它耗尽之前不断吃掉更多的内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM