在iframe中运行JavaScript时,是否存在CPU高的已知原因?

在iframe中运行JavaScript时,是否存在CPU高的已知原因?,javascript,html,internet-explorer,iframe,cpu-usage,Javascript,Html,Internet Explorer,Iframe,Cpu Usage,对于我当前的项目,一大块javaScript/jQuery运行了很长一段时间,很多很多天。它已经在Chrome/Firefox/internetexplorer中进行了测试 惊喜:它只在Internet Explorer中中断。它也只有在代码段在iframe中运行时才会中断 症状出现的速度很慢:CPU通常需要8/10个小时才能进入,因为它占用了运行它的线程的100%以上。因此,我很难找到调试它的方法 问:在iframe中运行JavaScript时,是否存在导致internetexplorer速度

对于我当前的项目,一大块javaScript/jQuery运行了很长一段时间,很多很多天。它已经在Chrome/Firefox/internetexplorer中进行了测试

惊喜:它只在Internet Explorer中中断。它也只有在代码段在iframe中运行时才会中断

症状出现的速度很慢:CPU通常需要8/10个小时才能进入,因为它占用了运行它的线程的100%以上。因此,我很难找到调试它的方法

问:在iframe中运行JavaScript时,是否存在导致internetexplorer速度减慢的已知bug/噱头

这是我的代码的一个粗略的运行过程,它非常粗糙,像SUDO一样

function setup() {

    readXML1(); // Ajax. Done once. Calls parseXML1() -> Creates array of variables.
    readXML2(); // Ajax. This repeats every 750ms. Sets a variable with the new "packet".
    readXML3(); // Ajax. Done once.Calls parseXML3() -> Creates array of variables.
    readXML4(); // Ajax. This repeats every 750ms. Sets a variable with the new "packet"

    bindSomeButtons(); // Create some toggling divs

    main();
}

function main() {
    var i, i2;

    parseXML1(); //  Checks for new packets. Creates/updates exampleObj's. These objects access the DOM.
    parseXML2(); // Checks for new packets. If so, this information updates an object, which accesses the DOM, including a table element.

    Settings.update();  // There .update() calls, use information supplied by readXML1/2 through parseXML1/2 to update stuff on the page.
    Connection.update();
    OtherStuff.update();

    for( i=0, i2 = gArr.Graphs.length; i<i2; i++ ) {
        Graphs[ i ].update(); // Uses information from readXML1 & parseXML1...
    }

    resizeParent(); // This calls parent.resize() with the calculates size of the iframe.

    setTimeout(main, 750);
};

var exampleObj = function( name, value ) {
    this.name = name;
    this.value = value;
    this.elem = $("."+name+", #"+name);
};

exampleObj.prototype.update = function( value ) {
    if( this.value != value ) {
        this.value = value;
        this.changeDOM(); // 
    }
};

exampleObj.prototype.changeDOM = function() {
    this.elem.empty().html( this.value );
}

您是否已尝试创建一个配置文件,以便可以发现瓶颈或内存泄漏?您是否可以混淆某些部分、更改变量名或用注释替换某些块,以便共享足够的代码来查看可能导致问题的原因?试着用“通用”代码重现这个问题。我现在正试着这么做。对不起,我意识到这个问题不符合SO的质量。这将需要我一段时间,我仍然需要大致追踪问题的起因。将尝试加速计时器等。看看这是否会导致问题更快地显示出来。在iframe中运行代码没有什么特别之处,除非代码本身检查是否在iframe中并以不同方式执行。@Barmar这很有帮助。非常感谢。我会浏览一下,看看有没有发生这种情况的地方。事实仍然是,这种情况只发生在。。。