Closed Bug 1357598 Opened 7 years ago Closed 7 years ago

Poor performance and high memory usage in Firefox after waking up computer from sleep

Categories

(Firefox :: General, defect)

51 Branch
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: info, Unassigned)

Details

(Whiteboard: [MemShrink])

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
Build ID: 20170125094131

Steps to reproduce:

Open Firefox and begin opening new tabs, memory usage increases on each new tab opened, memory usage does not appear to reduce to previous levels after closing tabs based on Windows Task Manager data. Sites like Facebook, LinkedIn or YouTube that have a heavy media load will use up memory faster then more text based sites and it will be more apparent that not all memory is released when a tab is closed.

I ran 2 separate memory tests run on about:memory done about 7 minutes apart. The first test shows the test shortly after launching Firefox, the 2nd after deliberately opening and closing a number of tabs on varoius social media sites (for this test I used Facebook and LinkedIn)

*I tried attaching the files but couldn't as the files were too big and would take too long to upload, I'll add the data from the logs in a reply.

Based on my tests, it does not matter what site is used, as long the page being opened consumes enough memory to make a noticeable change in Firefox's memory usage.


Actual results:

Memory usage (RAM) gradually increases whenever Firefox is allowed to run continuously, such as during daily work usage or long video watching or social media sessions.


Expected results:

When a tab is closed, all memory that tab used should be released back to the OS for general usage. RAM usage of Firefox should only be dependent on how many tabs/windows are open and the type and amount of contents on those pages, not how long it's been running for.
I'm unable to paste the text of the log as it crashes Firefox each time I attempt to do so and can't upload the file as this site complains the file it too big. I already tired uploading it as a zip file and that's the one it complained about. I'll have to find a safe place to upload the file to and add a link. Probably I'll create a Dropbox folder for the logs and post a link to that.
Created a folder for the logs in Dropbox. You can view the logs at https://www.dropbox.com/sh/4n2yai80gczpl55/AACl4rCtB-2OjU_joj-c74iia?dl=0

*Note:  If you don't see the files there, try again later, as the files may not have finished syncing yet. There should be 4 log files when syncing is done:

Files from first test, run shortly after opening Firefox:
- cc-edges.2464.1492555805-2017-04-18-3-50pm.log
- gc-edges.2464.1492555805-2017-04-18-3-50pm.log

This test I ran just a few minutes after opening Firefox. The only web pages I'd opened at this time were Yahoo (my home page) and a few pages/tabs in Bugzilla while searching for any existing reports on this issue.

Second test, run about 7 minutes after the first test:
- cc-edges.2464.1492556233-2017-04-18-3-57pm.log
- gc-edges.2464.1492556233-2017-04-18-3-57pm.log

This is the test I ran after opening several new tabs, mainly in Facebook and LinkedIn. This shows Firefox memory usage after opening these tabs.

If these tests do not point to the problem, I can run more memory tests again and post the results here later.
Whiteboard: [MemShrink]
Did you try to save a memory log from the page about:memory?
Flags: needinfo?(info)
(In reply to Loic from comment #3)
> Did you try to save a memory log from the page about:memory?

Yes, check the link in comment 2. I had to upload them to Dropbox as they wouldn't upload here.
Flags: needinfo?(info)
Jason, can you provide memory reports from about:memory? You can save them with "Measure and save..." under "Save memory reports".
Flags: needinfo?(info)
(In reply to Eric Rahm [:erahm] from comment #5)
> Jason, can you provide memory reports from about:memory? You can save them
> with "Measure and save..." under "Save memory reports".

Like I said before, I already did. CHECK THE DROPBOX LINK! How many times to I have to tell you that? Read the previous posts, it's right there in comment #2. Which I said in Comment #2 and again in comment #4. LOOK.

https://www.dropbox.com/sh/4n2yai80gczpl55/AACl4rCtB-2OjU_joj-c74iia?dl=0
Flags: needinfo?(info)
(In reply to Jason Ross from comment #6)
> (In reply to Eric Rahm [:erahm] from comment #5)
> > Jason, can you provide memory reports from about:memory? You can save them
> > with "Measure and save..." under "Save memory reports".
> 
> Like I said before, I already did. CHECK THE DROPBOX LINK! How many times to
> I have to tell you that? Read the previous posts, it's right there in
> comment #2. Which I said in Comment #2 and again in comment #4. LOOK.
> 
> https://www.dropbox.com/sh/4n2yai80gczpl55/AACl4rCtB-2OjU_joj-c74iia?dl=0

Those are CC/GC logs :) A set of memory reports would be more helpful for initial analysis. Thanks for the help!
Flags: needinfo?(info)
Also, I have another update to this issue. About a couple of hours ago, I left my computer unattended while I took care of something else, when I came back and woke my computer up from sleep mode, I found my computer lagging and when I finally managed to get the task manager open, I found it running at over 95% RAM used, and HD usage solidly at 100%. I couldn't get a memory report from that one as Firefox was unresponsive and even the Task Manager was going unresponsive. When I closed Firefox, RAM usage did not reduce at all. I have 8GB of RAM so it takes a lot of memory usage to use up that much. Firefox was using up the most memory, I don't know how much as I had to start closing tabs and anything else not critical to the OS just to get my computer somewhat responsive again. Even after closing everything but 1 tab, firefox was still using up over 550,000MB or RAM. I had to restart my computer to regain my RAM.

Since I'm basically finished working for the day, I can reboot again, open Firefox, run the memory test immediately on opening, open a bunch of tabs, run it again, then close all but one tab and run it a third time, that should give a clear enough picture of what's going on with the memory usage. If the files are small enough, I'll upload them here, but if I run into file size issues again, I'll add them to the Dropbox link posted above.
(In reply to Eric Rahm [:erahm] from comment #7)
> (In reply to Jason Ross from comment #6)
> > (In reply to Eric Rahm [:erahm] from comment #5)
> > > Jason, can you provide memory reports from about:memory? You can save them
> > > with "Measure and save..." under "Save memory reports".
> > 
> > Like I said before, I already did. CHECK THE DROPBOX LINK! How many times to
> > I have to tell you that? Read the previous posts, it's right there in
> > comment #2. Which I said in Comment #2 and again in comment #4. LOOK.
> > 
> > https://www.dropbox.com/sh/4n2yai80gczpl55/AACl4rCtB-2OjU_joj-c74iia?dl=0
> 
> Those are CC/GC logs :) A set of memory reports would be more helpful for
> initial analysis. Thanks for the help!

I don't know why you guys didn't just specify what reports you needed in the first place if the reports I'd submitted weren't the right ones.

In any case, I've re-run the tests and will be uploading the reports you need shortly.
Flags: needinfo?(info)
I did the following test and recorded 3 memory usage logs during the testing:

Rebooted system: Base RAM usage ~15-20% of total

Opened Firefox, navigated to about:memory: Firefox RAM Usage: ~195MB
Ran memory test #1 - 1 tab open, no navigating

Opened 2 more tabs (total 3 tabs open): Firefox RAM Usage: ~340MB (new tabs: Facebook, LinkedIn)

Opened 3 more tabs (total 6 tabs): Firefox RAM Usage: ~410MB (new tabs: Twitter, Dailymotion, YouTube)

Opened 4 more tabs (total 10 tabs) Firefox RAM Usage: ~630MB (same sites from here on)

Opened 5 more tabs (total 15 tabs): Firefox RAM Usage: ~850MB
Ran memory test #2 - 15 tabs open

Closed all tabs except about:memory: Firefox RAM Usage: ~450MB
Ran memory test #3 - 1 tab open, 14 tabs closed

I deliberately chose the sites that I knew would have the highest RAM load on my system, choosing busy social media and video sharing sites for this purpose. I monitored RAM usage with Windows Task Manager, as well as running the 3 memory tests on about:memory. 

As you can see from the data, RAM usage did not return to close to the baseline upon a clean open of Firefox. At the end of these tests, Total RAM usage was at about 28% of max.
One more thing, peak RAM usage was about 30-33% of my total of 8GB.
Thanks for the reports Jason, it looks like you're on an older version of Firefox. When you get a chance is it possible for you to upgrade to latest release? We've made some significant memory leak fixes in the past few releases.

It might help to also get a list of add-ons that you have enabled as those can increase memory usage as well. This information can be found in about:support. Some adblockers have been a particular issue for us.

Overall the memory usage I'm seeing in the reports isn't out of the ordinary for media-heavy sites.

Memory sticking around after closing tabs isn't completely unexpected, for example we can see ~100MiB in heap-overhead, this is memory available to our allocator but currently unused, and you can see ~20MiB in sqlite.places which I believe holds data about the pages you have previously opened. Additionally we have heuristics that kick in after a certain amount of time that will free up more memory after pages are closed. You can simulate this during measurement by clicking the GC, CC, and "Minimize Memory" buttons in about:memory.
Flags: needinfo?(info)
(In reply to Eric Rahm [:erahm] from comment #15)
> Thanks for the reports Jason, it looks like you're on an older version of
> Firefox. When you get a chance is it possible for you to upgrade to latest
> release? We've made some significant memory leak fixes in the past few
> releases.
> 
> It might help to also get a list of add-ons that you have enabled as those
> can increase memory usage as well. This information can be found in
> about:support. Some adblockers have been a particular issue for us.
> 
> Overall the memory usage I'm seeing in the reports isn't out of the ordinary
> for media-heavy sites.
> 
> Memory sticking around after closing tabs isn't completely unexpected, for
> example we can see ~100MiB in heap-overhead, this is memory available to our
> allocator but currently unused, and you can see ~20MiB in sqlite.places
> which I believe holds data about the pages you have previously opened.
> Additionally we have heuristics that kick in after a certain amount of time
> that will free up more memory after pages are closed. You can simulate this
> during measurement by clicking the GC, CC, and "Minimize Memory" buttons in
> about:memory.

I updated to the latest version and have been working all day with firefox running from about 10:30am to now. noticed my computer slowed down again after letting it sleep with Firefox running. RAM usage is now at about 85% of capacity again, the only programs using any significant amount of RAM at this time are Firefox and Malwarebytes. Malwarebytes does not seem to be having any issues with steadily increasing memory usage like Firefox does. I've only ever seen this issue of very high memory usage when firefox is running. Even when I shut it down once memory usage has hit this point, it does not free up the memory. I have to restart my computer to get the memory freed up. I'll run another memory test and see if we're getting any new results with the updates though. I should be on the 53.x branch now.
Flags: needinfo?(info)
Also, here's the data on my extensions:

Extensions
Name 	Version 	Enabled 	ID
Application Update Service Helper	2.0	true	aushelper@mozilla.org
Classic Theme Restorer	1.6.4	true	ClassicThemeRestorer@ArisT2Noia4dev
CodeBurner for Firebug	1.6.1-signed.1-signed	true	firebug@tools.sitepoint.com
CSS Usage	0.3.4.1-signed.1-signed	true	csscoverage@spaghetticoder.org
Download YouTube Videos as MP4	1.8.10	true	{b9bfaf1c-a63f-47cd-8b9a-29526ced9060}
DrupalForFirebug	2.2.1.1-signed.1-signed	true	DrupalForFirebug@drupal.org
Firebug	2.0.19	true	firebug@software.joehewitt.com
Firefinder for Firebug	1.4.1-signed.1-signed	true	firefinder@robertnyman.com
FireRainbow	1.5.1-signed.1-signed	true	firerainbow@hildebrand.cz
Free Download Manager extension	2.1.13	true	fdm_ffext@freedownloadmanager.org
Multi-process staged rollout	1.14	true	e10srollout@mozilla.org
Norton Security Toolbar	2017.9.1.7	true	{C1A2A613-35F1-4FCF-B27F-2840527B6556}
Privacy Badger	2017.4.19.1	true	jid1-MnnxcxisBPnSXQ-eff@jetpack
Web Compat	1.0	true	webcompat@mozilla.org
FireQuery	2.0.4	false	firequery@binaryage.com
MozBar	3.1.18	false	toolbar@seomoz.org
Pocket	1.0.5	false	firefox@getpocket.com
Please correct if this isn't the correct component. Cleaning up the Untriaged list.
Component: Untriaged → Tabbed Browser
I have another update on this issue.

Last Saturday, I was using Firefox for normal weekend usage. Basically, I loaded Firefox, and went to YouTube to watch a couple of videos in the morning, then let my computer sleep for a while, then opened it up and watched a few more videos, let it sleep again, basically going on and off my computer in this way, navigating to dailymotion for some videos there at one point, and I think I did a search at one point too, but nothing crazy, I barely opened any different tabs, and I did open and close Firefox a few times during the course of the day. By the evening, I had to reboot my computer due to excessive RAM usage (over 90% capacity, heavy pagefile use), yet Firefox was only claiming about 500mb of memory according to the Task Manager. This seemed strange to me, so on Sunday, I decided to do an experiment, and went the entire day not using Firefox at all, switching all my browsing to Chrome for the day. RAM usage remained fairly normal, ranging from about 20% to about 35% during the times I checked in Task Manager. The only difference was that I did not load up Firefox at any point during that day after doing a cold boot in the morning. Today, I'm using Firefox again, and noticed RAM usage has again crept up during business usage. RAM usage on my computer starts at a baseline of about 20-24% on bootup, but is now running at about 40% usage, and when I close Firefox (and any other apps that I start up later), it never goes back down to that baseline. So somewhere along the way, Firefox is consuming RAM and not releasing it, even upon closing the program.

Another thing is that this issue seems to have started after I updated to the version 51 branch, and updating to the 53 branch has NOT solved this issue. the last branch I used where this memory usage issue was not a problem as I think 48 or 49. It's been a few weeks since I updated to v51 and then to v53, so I don't remember exactly what version I was on before I noticed this issue. I do know I skipped v50, so don't know if this memory leak was a problem then or not.
Also, this issue does not seem to be limited to using tabs. Just surfing the internet alone seems to be enough to cause this issue. Letting the computer go into sleep mode and waking it back up again with Firefox still running does seem to accelerate Firefox's RAM usage problem, as does opening tabs, but I think the tabs are just because they use up more RAM faster then single tab browsing more then anything. One thing to consider is it may be that Firefox is not fully clearing out RAM usage after downloading and displaying web contents. It also may have an issue with RAM handling when the computer is going into and waking up from sleep mode. This behavior is unconfirmed and I'd appreciate it if anyone could test Firefox on their own systems to see if others are having similar issues or not.
Thanks Jason, so it sounds like you have a few issues, I'm going to break these down and re-purpose this for what sounds like the most egregious issue.

#1 - The performance of Firefox is awful after waking up from sleep mode. High CPU usage, high memory usage, lots of disk access.

#2 - Even after closing Firefox your computer still has high memory usage. This would indicate that there's a bad interaction with another program, all memory allocated by Firefox should be freed by the operating system. You mention you use Malwarebytes and you also have "Norton security toolbar" installed. It's possible one of those is having a bad interaction with Firefox. It might be worth testing with those temporarily disabled.

#3 - RAM usage creeps up during the day, which feels like a leak, but after closing Firefox the memory isn't freed. This feels like #2.
Component: Tabbed Browser → General
Summary: Possible Memory Leak → Poor performance and high memory usage in Firefox after waking up computer from sleep
(In reply to Eric Rahm [:erahm] from comment #21)
> Thanks Jason, so it sounds like you have a few issues, I'm going to break
> these down and re-purpose this for what sounds like the most egregious issue.
> 
> #1 - The performance of Firefox is awful after waking up from sleep mode.
> High CPU usage, high memory usage, lots of disk access.
> 
> #2 - Even after closing Firefox your computer still has high memory usage.
> This would indicate that there's a bad interaction with another program, all
> memory allocated by Firefox should be freed by the operating system. You
> mention you use Malwarebytes and you also have "Norton security toolbar"
> installed. It's possible one of those is having a bad interaction with
> Firefox. It might be worth testing with those temporarily disabled.
> 
> #3 - RAM usage creeps up during the day, which feels like a leak, but after
> closing Firefox the memory isn't freed. This feels like #2.

Regarding the Norton Toolbar, that's been disabled for most of the time I've been having this issue, so it's unlikely the cause. I can go through and test the other add-ons at a later date when I have more time to test things but they're all the same ones I've had for years mostly, and all of them have been active even before the problems started, so if there's a bad interaction, it has to have started as a result of a recent Firefox update causing it.

The main area where there may be a conflict is between Malwarebytes and Firefox. I updated both around the same time, firefox to v51.x, Malwarebytes to v3.x, however, I don't have any Malwarebytes add-ons installed on Firefox, so I'm not sure how they could be affecting each other or RAM usage.

Is it possible there's a component of Firefox that's not shutting down when I "close" the program? Perhaps a process that runs in the background with no visible window and does not appear in the Task Manager? If so, then it may be that if there is a memory leak, the RAM does not get released by the OS as it still "sees" a component of firefox running, so holds all RAM reserved by Firefox, thus causing the evergrowing RAM usage. An add-on could be the component, I suppose, but I really don't know without further testing which it might be, as, like I said, I've been running all the ones I have for months before this issue started, with the exception of the Norton toolbar, which was disabled until after this problem started.
(In reply to Jason Ross from comment #22) 
> Regarding the Norton Toolbar, that's been disabled for most of the time I've
> been having this issue, so it's unlikely the cause. I can go through and
> test the other add-ons at a later date when I have more time to test things
> but they're all the same ones I've had for years mostly, and all of them
> have been active even before the problems started, so if there's a bad
> interaction, it has to have started as a result of a recent Firefox update
> causing it.

Yes, it's useful for us to determine if newer versions of Firefox interact poorly with older add-ons.

> The main area where there may be a conflict is between Malwarebytes and
> Firefox. I updated both around the same time, firefox to v51.x, Malwarebytes
> to v3.x, however, I don't have any Malwarebytes add-ons installed on
> Firefox, so I'm not sure how they could be affecting each other or RAM usage.

Unfortunately some AV vendors hook our processes to intercept calls, they also often install something called a "filter driver" which could have bad interactions, no add-on necessary.

> Is it possible there's a component of Firefox that's not shutting down when
> I "close" the program? Perhaps a process that runs in the background with no
> visible window and does not appear in the Task Manager?

You can use a tool like process explorer [1] to get a better look at what processes are running. We have a few that we use: the main process is 'firefox.exe', there might also be 'updater.exe' and 'maintenanceservice.exe', and if flash is enabled you might see 'plugin-container.exe'. These should all generally have 'firefox' in their path. If those stick around after you close the browser that's definitely a bug.

[1] https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx
Jason, were you able to test with AV/addons disabled? Did you see anything suspicious in process explorer?
Flags: needinfo?(info)
(In reply to Eric Rahm [:erahm] (PTO May 4 - 8) from comment #24)
> Jason, were you able to test with AV/addons disabled? Did you see anything
> suspicious in process explorer?

I haven't had time to test anything yet. Although I did confirm 2 of my colleagues are also having serious issues with the current version of Firefox. I'll send them the link to this thread so they can do any tests and confirm if they're issues are in any way related to this one or not. From what they described it's possible they're getting the same bug.
Flags: needinfo?(info)
(In reply to Eric Rahm [:erahm] (PTO May 4 - 8) from comment #23)
> (In reply to Jason Ross from comment #22) 
 
> You can use a tool like process explorer [1] to get a better look at what
> processes are running. We have a few that we use: the main process is
> 'firefox.exe', there might also be 'updater.exe' and
> 'maintenanceservice.exe', and if flash is enabled you might see
> 'plugin-container.exe'. These should all generally have 'firefox' in their
> path. If those stick around after you close the browser that's definitely a
> bug.
> 
> [1] https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx

I just installed Process Explorer and for my first test, I opened Firefox, did a search on all handles and DLLs Firefox was using and got 192 results, closed Firefox and got 0 results.

Opening Firefox and navigating to YouTube and starting a video is my next test.

Results: 61 Files and DLLs found associated with Firefox. All files were showing as "<Non-existent process>"

After closing Firefox, I re-ran the search and found no results.

After both tests, I don't see any sign of any programs hanging around after closing Firefox.

If you have any other tests you can recommend I run on Process Explorer or any other software, let me know. I'll check on Add-ons at a later date.

One thing I will note is that this issue has gotten so bad I can't even use Firefox right now. I've had to switch to using Chrome for my main browser for the last week. Since Sunder I've only opened Firefox briefly about 4 or 5 times (mostly either by mistake out of habit, or because I clicked something that opened it as it's my default browser), and still noticed my RAM usage has crept up to double the standard startup usage. So this issue is even happening with only brief usage.

Whatever the issue is, it definitely involves firefox as I only have this memory issue when I run it.
Jason are you still seeing this? We think that some recent changes may help performance in this case. If so I'll try to get you connected with one of our profiling experts to help triage the issue further.
Flags: needinfo?(info)
I'm going to close this for now, but feel free to reopen if you still have the issue.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(info)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: