starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
阅读:4676回复:15

FF似乎用得稍久就不能开about:memory了(发现是一个GM脚本搞的)

楼主#
更多 发布于:2013-05-12 11:28
最近FF用得比较久之后就会很卡,本来想开about:memory看看是不是那个扩展内存泄露了,结果就看到一行报错:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMemoryMultiReporter.collectReports]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://global/content/aboutMemory.js :: processMemoryReporters :: line 213"  data: no]
这太蠢了!
这几天重复试了几下,基本只有FF刚开的时候还能看about:memory,用得稍久后就一定会报这个错了。
这到底是什么奇怪的bug……
brucmao
火狐狸
火狐狸
  • UID39549
  • 注册日期2013-05-29
  • 最后登录2020-03-25
  • 发帖数101
  • 经验154枚
  • 威望0点
  • 贡献值134点
  • 好评度5点
1楼#
发布于:2013-12-27 11:22
我用UC脚本查看内存

图片:QQ截图20131227112311.png



// ==UserScript==
// @name  MemoryMonitorMod.uc.js
// @compatibility  Firefox 9.*
// @description  Bei Ueberschreitung der maximalen Speicherauslastung kann automatischer Neustart durchgefuehrt werden
// @include  main
// @note  Bezug: about:memory
// @note  http://loda.jp/script/?id=584
// @note  Version auf https://github.com/ardiman/userChrome.js um _autoRestart und Fehlerumgehung bei gfx-surface-image ergaenzt
// ==/UserScript==
const version = Services.prefs.getCharPref("extensions.lastPlatformVersion").split(".",1);
var ucjs_MemoryMonitor = {
  // ---------------------------------setting data-----------------------------
  // Update-Intervall[ms]
  _interval: 5000,
  // Neustart bei maximaler Speichernutzung (Achtung! Anpassen an die darunter gewaehlte Speichereinheit)
  _maxMemory: 500,
  // Speicher-Einheit: B, KB, KiB, MB, MiB, GB, GiB
  _prefix: "MB",
  // Speicher-Einheitanzeige in der Statusbar
  _dPrefix: true,
  // automatischen Restart bei Ueberschreitung von _maxMemory durchfuehren
  _autoRestart: false,
  // --------------------------------------------------------------------------
  interval: null,
  init: function () {
    var memoryPanel = document.createElement("statusbarpanel");
    memoryPanel.id = "MemoryDisplay";
    memoryPanel.setAttribute("label", this.setPrefix(this._dPrefix));
    document.getElementById("urlbar-icons").insertBefore(memoryPanel, null);
    this.start();
    this.interval = setInterval(this.start, this._interval);
  },
  
  addFigure: function (str) {
    var num = new String(str).replace(/,/g, "");
    while (num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    return num;
  },
  
  restart: function () {
    var appStartup = Components.interfaces.nsIAppStartup;
    Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(appStartup).quit(appStartup.eRestart | appStartup.eAttemptQuit);
  },
  
  getSize: function (mem, flag) {
    var pre = 1;
    switch (this._prefix) {      
      case 'KB':
        pre = 1000;
        break;
      case 'KiB':
        pre = 1024;
        break;
      case 'MB':
        pre= 1000 * 1000;
        break;
      case 'MiB':
        pre = 1024 * 1024;
        break;
      case 'GB':
        pre = 1000 * 1000 * 1000;
        break;
      case 'GiB':
        pre = 1024 * 1024 * 1024;
        break;
    }
    if (flag) return mem * pre;
    else return ucjs_MemoryMonitor.addFigure(Math.round(mem / pre));
  },
  
  setPrefix: function (flag) {
    return (flag) ? " " + this._prefix : "";
  },
  
  start: function () {
    try {
      const Cc = Components.classes;
      const Ci = Components.interfaces;
      var mgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
      var e = mgr.enumerateReporters();
      var gMemReporters = {};
      if(version<=25){
        while (e.hasMoreElements()) {
            var mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
            gMemReporters[mr.path] = mr;}
      }
      if(version>25){
        var handleReport = function(Process, Path, Kind, Units, Amount, Description) {
            gMemReporters[Path] = {};
            gMemReporters[Path].amount = Amount;
        }
        var MEM_HISTOGRAMS = {};
        while (e.hasMoreElements()) {
            let mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
            MEM_HISTOGRAMS[mr.name] = mr.name;
            if(!MEM_HISTOGRAMS[mr.name] || ["resident","private","gfx-surface-image"].indexOf(mr.name)==-1) continue;
        try{
            mr.collectReports(handleReport, null);
            }catch(ex){}
        }
      }
      var workingSet = gMemReporters["resident"].amount;
      var commitmentSize=(typeof(gMemReporters["private"])!="undefined" ? gMemReporters["private"].amount : 0);
      var gfxImage=(typeof(gMemReporters["gfx-surface-image"])!="undefined" ? gMemReporters["gfx-surface-image"].amount : 0);
      var restartMemory = ucjs_MemoryMonitor.getSize(ucjs_MemoryMonitor._maxMemory, true);
      var memoryPanel = document.getElementById("MemoryDisplay");
      memoryPanel.setAttribute("label", ucjs_MemoryMonitor.getSize(workingSet) + ucjs_MemoryMonitor.setPrefix(ucjs_MemoryMonitor._dPrefix));
      memoryPanel.setAttribute("onclick", "openUILinkIn('about:memory','tab')");
      memoryPanel.setAttribute("tooltiptext", 
        ((workingSet) ? "resident: " + ucjs_MemoryMonitor.getSize(workingSet) + " " + ucjs_MemoryMonitor._prefix + "\n" : "") + 
        ((commitmentSize) ? "private: " + ucjs_MemoryMonitor.getSize(commitmentSize) + " " + ucjs_MemoryMonitor._prefix + "\n" : "") + 
        ((gfxImage) ? "gfx-surface-image: " + ucjs_MemoryMonitor.getSize(gfxImage) + " " + ucjs_MemoryMonitor._prefix : "")
      );
     if (workingSet > restartMemory) {
        if (memoryPanel.style.backgroundColor == "red" && ucjs_MemoryMonitor._autoRestart) ucjs_MemoryMonitor.restart();
        else memoryPanel.style.backgroundColor = "red";
      } else if (workingSet > restartMemory * 0.8) memoryPanel.style.backgroundColor = "#FF99FF";
      else if (workingSet > restartMemory * 0.6) memoryPanel.style.backgroundColor = "#FFFF99";
      else memoryPanel.style.backgroundColor = "transparent";
    } catch (e) {
      clearInterval(ucjs_MemoryMonitor.interval);
      alert("ucjs_MemoryMonitor Err:" + e);
    }
  }
}
  
ucjs_MemoryMonitor.init();
@brucmao
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
2楼#
发布于:2013-12-22 07:53
pcxfirefox:你确定哪个版本没问题,哪个版本开始出现的问题吗?我希望解决这个问题回到原帖
21有这个问题,20没有。
这个问题和沙盒的名字有关,greasemonkey会用脚本的名字创建一个沙盒,这个过程会造成内存泄漏。
https://bugzilla.mozilla.org/show_bug.cgi?id=875348 这是bugzilla上面的相关报告。
pcxfirefox
千年狐狸
千年狐狸
  • UID39042
  • 注册日期2012-06-22
  • 最后登录2018-01-15
  • 发帖数2539
  • 经验1263枚
  • 威望2点
  • 贡献值242点
  • 好评度133点
  • 最爱沙发
  • 忠实会员
  • 社区居民
3楼#
发布于:2013-12-17 22:58
starrin:重新测试了一下,发现这个bug比想象中的还要蠢。是中文脚本名的问题。如果GM脚本的脚本名中带有中文就能引发这个bug。
这应该是FF beta的一个bug,在stable下面都无法复现。
回到原帖
你确定哪个版本没问题,哪个版本开始出现的问题吗?我希望解决这个问题
http://pcxfirefox.wordpress.com/
fang5566
管理员
管理员
  • UID3719
  • 注册日期2005-03-07
  • 最后登录2024-06-03
  • 发帖数18483
  • 经验4837枚
  • 威望5点
  • 贡献值4316点
  • 好评度1116点
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 终身成就
4楼#
发布于:2013-05-12 11:28
starrin
我也用aurora实验了一会儿。至少当脚本名字是5个或更多个汉字的时候,这个bug是可以在aurora上复现的。名字是4个汉字的脚本不会有问题。
回到原帖


如果是firefox本身问题,可以考虑汇报一个bugzilla的bug
Firefox More than meets your experience
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
5楼#
发布于:2013-05-12 11:28
fang5566:aurora正常,那应该下一个beta版本会解决回到原帖

我也用aurora实验了一会儿。至少当脚本名字是5个或更多个汉字的时候,这个bug是可以在aurora上复现的。名字是4个汉字的脚本不会有问题。
fang5566
管理员
管理员
  • UID3719
  • 注册日期2005-03-07
  • 最后登录2024-06-03
  • 发帖数18483
  • 经验4837枚
  • 威望5点
  • 贡献值4316点
  • 好评度1116点
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 终身成就
6楼#
发布于:2013-05-12 11:28
aurora正常,那应该下一个beta版本会解决
Firefox More than meets your experience
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
7楼#
发布于:2013-05-12 11:28
重新测试了一下,发现这个bug比想象中的还要蠢。是中文脚本名的问题。如果GM脚本的脚本名中带有中文就能引发这个bug。
这应该是FF beta的一个bug,在stable下面都无法复现。
yfdyh000
千年狐狸
千年狐狸
  • UID29079
  • 注册日期2009-06-07
  • 最后登录2022-05-18
  • 发帖数2262
  • 经验1390枚
  • 威望0点
  • 贡献值52点
  • 好评度139点
  • 社区居民
  • 最爱沙发
  • 忠实会员
8楼#
发布于:2013-05-12 11:28
Re: FF似乎用得稍久就不能开about:memory了……
starrin:……排查出来了。是新浪微博上的那个GM脚本,“眼不见心不烦”。
我是不太明白为什么一个GM脚本能造成FF本身的BUG啦……
刚才为了确认,我专门新建了一个profile,只装了Greasemonkey,然后去装了这个脚本,开一下新浪微博,刷新一下about:memory,就出现报错了。
回到原帖

我没装那个脚本。但装了另一个GM脚本,一生效运行这about就会开始报错了,然后过一段时间(几十秒,大概是自动垃圾清理了)这就恢复了。
用的Greasemonkey 1.8,Firefox 21。看来可能Greasemonkey或者Firefox的bug,像是兼容性问题,收集信息出错了。
fang5566
管理员
管理员
  • UID3719
  • 注册日期2005-03-07
  • 最后登录2024-06-03
  • 发帖数18483
  • 经验4837枚
  • 威望5点
  • 贡献值4316点
  • 好评度1116点
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 终身成就
9楼#
发布于:2013-05-12 11:28
嗯,脚本问题的话最好回报给作者。
Firefox More than meets your experience
pcxfirefox
千年狐狸
千年狐狸
  • UID39042
  • 注册日期2012-06-22
  • 最后登录2018-01-15
  • 发帖数2539
  • 经验1263枚
  • 威望2点
  • 贡献值242点
  • 好评度133点
  • 最爱沙发
  • 忠实会员
  • 社区居民
10楼#
发布于:2013-05-12 11:28
据说是有的脚本导致GM内存泄漏出现的这个情况
http://pcxfirefox.wordpress.com/
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
11楼#
发布于:2013-05-12 11:28
Re: FF似乎用得稍久就不能开about:memory了……
……排查出来了。是新浪微博上的那个GM脚本,“眼不见心不烦”。
我是不太明白为什么一个GM脚本能造成FF本身的BUG啦……
刚才为了确认,我专门新建了一个profile,只装了Greasemonkey,然后去装了这个脚本,开一下新浪微博,刷新一下about:memory,就出现报错了。
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
12楼#
发布于:2013-05-12 11:28
Re: FF似乎用得稍久就不能开about:memory了……
我新建了一个profile之后确实没有这个问题了,看来需要排查我原来装的那一堆扩展……唉。
starrin
小狐狸
小狐狸
  • UID39387
  • 注册日期2013-04-16
  • 最后登录2015-08-30
  • 发帖数21
  • 经验24枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
13楼#
发布于:2013-05-12 11:28
Re: FF似乎用得稍久就不能开about:memory了……
fang5566:用22.0a开了一个半小时,about:memory 一直都正常打开。回到原帖

悲剧,我新建一个profile试试。
fang5566
管理员
管理员
  • UID3719
  • 注册日期2005-03-07
  • 最后登录2024-06-03
  • 发帖数18483
  • 经验4837枚
  • 威望5点
  • 贡献值4316点
  • 好评度1116点
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 终身成就
14楼#
发布于:2013-05-12 11:28
Re: FF似乎用得稍久就不能开about:memory了……
用22.0a开了一个半小时,about:memory 一直都正常打开。
Firefox More than meets your experience
上一页
游客

返回顶部