javascript - 清除 Tampermonkey 的浏览器选项卡 RAM 使用情况吗?

标签 javascript google-chrome memory-management tampermonkey

我正在寻找一种使用 Tampermonkey for Chrome 注入(inject) JavaScript 的解决方案,每次重新加载页面都会清除 RAM 的使用情况,而不是增加它。

我正在使用 Chrome 开发者工具->时间线对注入(inject)的脚本进行测试。每次重新加载页面时,RAM 使用量都会增加。

我的 javascript 包含一些 jQuery AJAX 调用和几行代码。

我尝试了所有可能的 javascript 重新加载函数,但没有一个给出我想要的结果。

因此,如果有人知道如何解决这个问题,我将非常感激。

最佳答案

更新:
I've fixed a memory leak in Tampermonkey这导致即使在页面重新加载后,某些数据仍保留在内存中。所以也许你的问题现在已经解决了。

<小时/> <小时/>

选择另一个选项卡并等待几秒钟。没有其他方法可以触发垃圾收集。

也许你可以使用这个魔法来假装完全重新加载:

// ==UserScript==
// @name       fake reload
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  enter something useful
// @match      http://tampermonkey.net/empty.html
// @copyright  2012+, You
// ==/UserScript==

function fake_reload() {
    console.log("...now");
    GM_openInTab(window.location.href, {active: false, insert: true});
    // close the current window some ms later to allow the insert magic to detect this' tab position
    window.setTimeout(window.close, 1);
}
window.setTimeout(fake_reload, 3000);
console.log("run 'fake reload'...");

关于javascript - 清除 Tampermonkey 的浏览器选项卡 RAM 使用情况吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13828755/

相关文章:

javascript - Angular ng-repeat View 在搜索后不会更新

css - 为什么 Chrome 打破了这种布局?

google-chrome - Google Chrome开发人员工具无法在Elements标签中显示正文内容

javascript - 如何记录我的 javascript 代码中垃圾收集的内容?

c++ - 将 C++ vector 作为成员放入使用内存池的类中

javascript - 在React Final Form中,为嵌套字段提供initialValues

javascript - 将事件绑定(bind)到动态生成的表单

javascript - 如何在窗口调整大小时禁用和启用 ScrollMagic?

c++ - 在作为函数参数传递的指针上使用 delete

c - 我如何发现 Valgrind 中被抑制的错误?