Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 direct 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.

like image 748
jAndy Avatar asked Aug 22 '11 10:08

jAndy


2 Answers

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.

like image 173
Wladimir Palant Avatar answered Oct 16 '22 16:10

Wladimir Palant


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/

like image 28
Russ Clarke Avatar answered Oct 16 '22 18:10

Russ Clarke