Firefox causes excessive page faults (appears to be memory compaction)

RESOLVED INCOMPLETE

Status

()

Firefox
Untriaged
RESOLVED INCOMPLETE
6 years ago
2 years ago

People

(Reporter: michael-bugzilla-firefox, Unassigned)

Tracking

17 Branch
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.11) Gecko/20100101 Firefox/10.0.11
Build ID: 20121115102332

Steps to reproduce:

I was using a different program, fairly memory hungry (Java game; "minecraft") while firefox was sitting in the background, doing nothing.


Actual results:

As reported by Activity Monitor (think GUI interface to "top"), when I quit Minecraft, firefox's memory usage went from about 200MB back up to over 800MB, without any interaction with it from me.


Expected results:

If a program is sitting around, not doing anything, then it should sit around and not do anything. Programs that actually must keep their memory in use are just badly behaved.

In the case of firefox, since it seems to have some form of internal garbage collection, it seems that it wants to walk all of the data pages to collect garbage, and force everything into memory. Now, granted, that's kind of hard to avoid in a GC system.

But it can be smarter. 

NB: This is a 10 ESR version. I've got two machines running TenFourFox, and this one, all syncing profiles. TenFourFox just released a 17ESR version, so I'll be switching to that real soon now; if this has been solved by 17, then just close this, and I apologize.
waiting for FF17 results as FF10ESR is soon EOL
Flags: needinfo?(michael-bugzilla-firefox)
(Reporter)

Comment 2

6 years ago
Tested with 17.

Initial testing had 2GB of free memory. Loaded, allowed all tabs to load, memory consumption was 1.3gb at the peak.

Next: running other programs, letting firefox "fight" for resident pages. 1.2 GB.

Hide all windows. Suspend. Let it get "mostly paged out" to only about 20mb resident (seriously, why are the "select page to swap out" routines so badly willing to leave unused memory in RAM and put wanted pages out instead? It took hours to get FF down that far).

Sent a CONT signal. Firefox went up to 853MB.

Again: That was with no windows displayed, no interactions of any kind except for messages queued while paused.

Displayed windows. No change in memory usage. (OS: Mac 10.6.8)

The frontmost window was "about:memory". So, I hit "minimize memory usage".

Memory in use went up to 1.07gb.

Conclusion: Firefox, even in 17, seems to be paging in almost all data pages on a regular basis.
Expected behavior: Data pages referring to web pages that are not displayed (background tabs) or windows that are not being refreshed (not visible) will not be touched, nor read.

I don't know how deep of a memory issue this is. 

If I could do a full redesign of memory behavior (this is probably not possible), I'd make sure that all data related to a single web page was compacted into a single block of memory. As a first idea for implementation, one pass would identify all the memory needed for a single page (think "mark-sweep" starting from that page's top object), then allocate a block of memory from the operating system for that size plus some "surplus"(assuming that further usage of that page would grow it a little), then copy (as in "survivor space copy") all the objects for that page to that block. Then, mark that block as belonging to that top level object, and clean.

Do this for each web page.

Now unallocate all the old storage blocks, returning them to the operating system. This step might not be "portable" :-).

During future compaction, a "clean" block can be ignored -- and the top level object for that web page can track if the details for that page are clean or not.

When the page is displayed (tab brought to the front), clicks arrive, javascript events arrive, etc, then the page gets "unclean" until the next mark-sweep-copy.

In other words, rather than one global pool of memory to clean up, each page gets its own pool of memory, plus a shared eden space as needed.

Now, Firefox is not Java. So I don't know how well these ideas will translate. I don't even know if this is cross-operating system possible or not.

Tab count:
First window: About:memory
Second window: 14 tabs from forum at "minecraftforum.net"
Third window: 3 tabs from "macrumors.com" and "mac-forums.com"
Fourth window: 2 from github, one from ffmpegx.com
Fifth window: 10 from wikipedia, and the front page from "justicepartyusa.org"
Sixth window: 5 from gameful.org, one from youtube.com (noscript prevented flash player from loading), homepage from ted.com
7th window: 9 from Oracle, one each from linkedin, slideshare.net, and petefreitag.com
8th window: brothersoft.com login page.

Hmm, I keep my windows mostly organized, only a little cross-pollination going on. Not sure why 10 pages on particle physics are sharing a window with a political reform third party.

Note: During this message, going over all the windows, bringing up at least the titles of all pages, memory usage went up to 1.16 GB. 

For completeness, actually going top to bottom of all web pages: up to 1.19GB.

So, highest memory usage I can get: 1.19 gb.
Memory usage minimum: 853 MB
Memory usage after compacting memory: 1.07 gb.

Yes, I'd say firefox still wants to have almost all of its pages resident, even when not active, which is not friendly on a multi-tasking system. And seriously impacts it's ability to run on low memory machines if you want to use multiple tabs/windows.
Flags: needinfo?(michael-bugzilla-firefox)

Comment 3

6 years ago
I see similar issues and my memory goes to 1.5 GB when browser start getting very slow. I am at the point of dumping Firefox and look into Chrome or even IE. Any plans to get this fixed?
(Reporter)

Updated

5 years ago
Version: 10 Branch → 17 Branch
Hi Michael,

I'm unsure what the issue is here, is it the fact that Firefox uses a lot of memory? Or does it cause slowness due to the memory usage? Have you encountered the same issue using more recent Firefox editions?

In my opinion 1.19 GB of for so many tabs it's normal. At least for current PC configurations. However, I think Chrome uses somewhere around the same value if you sum up all it's processes. 

Could you please try the latest Firefox release(43.0.4) and the latest Nightly (https://nightly.mozilla.org) and provide the results? 

Thanks,
Cipri
Flags: needinfo?(michael-bugzilla-firefox)
Since the reporter didn't provide the requested information, I will mark this issue as RESOLVED INCOMPLETE. If you still encounter this problem, please feel free to reopen this bug, or file a new one.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago
Flags: needinfo?(michael-bugzilla-firefox)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.