检测带有内置内存泄漏的 IE11 何时耗尽内存(1.5GB 可回收池)

Edz*_*dza 6 javascript performance memory-leaks internet-explorer-11 vue.js

IE11 有一个有据可查的 iframe 内存泄漏。在 SPA 中,如果您使用 iframe,内存将增长到大约 1.5GB,之后它会变慢直到崩溃。

我的任务是检测浏览器何时崩溃并尽快重新启动页面。该应用程序是嵌入在 ASP.NET MVC 中的 Vue.JS。

IE11 浏览器中提供了哪些内存/性能检测?

  • 某种使用过的内存测量库?
  • 某种性能测量库?
  • 计算创建的 javascript 对象?
  • 计算创建的 iframe?

其他想法?谢谢。:)

来源:https : //developer.microsoft.com/en-us/microsoft-edge/platform/issues/10186458/ https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8449104/ http://support.sas.com/kb/60/514.html

Edz*_*dza 1

这就是我最终用来检测 IE11 内存不足的方法。

主要思想:每1秒定时器一次。如果 1 秒计时器需要 1 分钟,我们就会僵住。

var startTime, endTime;

function start() {
    startTime = new Date();
};

function end() {
    endTime = new Date();
    var timeDiff = endTime - startTime; //in ms
    // strip the ms
    timeDiff /= 1000;

    // get seconds 
    var seconds = Math.round(timeDiff);
    console.log(seconds + " seconds");

    if (seconds > 60)
        console.log("IE11 just froze. We need to refresh.");
}

start();

setInterval(function () {
    end();

    start();
}, 1000);
Run Code Online (Sandbox Code Playgroud)