开发者

How to read Firefox "about:memory" correctly?

In Firefox (I guess since Firefox 4) we have the about:memory page. Even if I'm quite familiar with C/C++ dynamic memory management, I have to admit I don't really know how to read that page.

I was hoping about:memory would give me, as JavaScript/front-end developer, a better way to detect/find memory leaks, created in ECMAScript and/or DOM scripting. I'm testing on a Windows 7 and a Mac OS X Snow Leopard system.

So I've got a few questions and hopefully someone can answer those (please don't guess if you are not sure).

  • Windows 7 difference between win32/privatebytes and Memory in use.

This really annoys me. If I'm doing some heavy ECMAScript/DOM operations, the former value seems to increase to no end, where in contrast Memory in use keeps being "smallish". Which value is really interesting here? It looks like win32 privatebytes is the same value that you can see in your Task Manager.

  • What is the difference between Memory mapped and Memory in use?

I'm googling for quite a while on this one. Some people say it indicates how much of the memory in use is fragmented. What does that mean in detail? Is that a dir开发者_运维知识库ect indicator for memory leaks?

I'd be happy if someone could explain most of the values just a little (or link a resource which I didn't find). But, most interesting for me is the big gap between those win32 privatebytes and the browsers memory usage. Max OS X does not seem to have an equivalent for those values, which I guess is because of a fundamental different memory management system.


This mozilla blog seems to explain it quite well, and if not, then you've got the contact details of someone who would know:

http://blog.mozilla.com/nnethercote/2011/05/23/a-better-aboutmemory-stage-1-75/


You should only care about the memory actually used by the browser. There will always be more memory allocated at the OS level, due to memory fragmentation etc. But that's really something that only browser developers need to think about. If you see a reproducible pathological behavior - file a Mozilla bug (minimized testcase needed). But other than that you should only make sure that your code doesn't hoard objects that cannot be released (which is visible by the memory used).

I'm not sure whether "memory mapped" is even visible in the new version of about:memory, maybe under a new name. I'm pretty sure that you shouldn't care about it however. That's the amount of memory that has an address assigned to it, something that's only interesting on the OS level.


Answering the generic question in the thread's title, and not the specific questions, which seem to be resolved:

  • Hover the measurement you're interested in. They have tooltips with some explanation.
  • If you're interested in details, it's sometimes illuminating to read the discussion (in bugzilla) behind the measure.
    To find the discussion, search the mozilla code for the measure name, e.g. http://mxr.mozilla.org/mozilla-central/search?string=heap-dirty , select 'Hg Blame' link, click the link before the line with the measure's name (it looks like <user>@<revid>), and click the changeset link (like changeset NNNNNN a6b3a22fbca7) then click on the bug link.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜