Enabling javascript causes high CPU and memory usage spikes




JavaScript Engine
9 years ago
3 years ago


(Reporter: Sunil, Unassigned)


1.9.1 Branch

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [closeme 2011-01-31])


(2 attachments)



9 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20091110 Gentoo Firefox/3.5.5
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20091110 Gentoo Firefox/3.5.5

I was observing continuous high usage by firefox on my laptop and tried to see if I can nail it down to some add-on or a feature. This is what I arrived at finally: Javascript is a CPU and memory hog. This is what I did to test this.

1. Disabled javascript and restarted firefox in safe mode.
2. Opened about 25 tabs(my usual websites) in 3 windows. Two of these are known to use javascript: gmail and yahoo mail.
3. Let it idle for a bit.
4. Fired: fpid=`/bin/ps -aef|grep [f]irefox|awk '{print $2}'`;top -b -p $fpid|grep $fpid and routed to a file for 30 seconds.
5. Then, I enabled JS and restarted firefox in safe mode.
6. Opened the same set of tabs.
7. Let it idle.
8. Fired the same command again with a different output filename.

Results are attached. As you can see, the memory footprint is much bigger with JS enabled. CPU usage in general is always greater than 5% (never 0%) and spiking whenever yahoo mail or gmail refreshes, whereas without JS, it drops to 0% when idling and is mostly below 5%.

Reproducible: Always

Steps to Reproduce:
1. Enabled JS and run
2. Higher CPU usage and memory usage
3. Disable JS and compare.

Comment 1

9 years ago
Created attachment 414082 [details]
Without JS

CPU usage less than 5% and 0% idling.

Comment 2

9 years ago
Created attachment 414083 [details]
With JS enabled.

Higher memory usage, higher CPU usage spikes at 38%. Generally, the CPU usage is high (most samples greater than 5%) although the browser is idling.

Comment 3

9 years ago
This basically eats up my laptop battery just lying idle. So, its a major problem.

Comment 4

9 years ago
Lots of web apps use JS timers with a high frequency. 38% sounds a bit insane though.

Comment 5

8 years ago
please provide a couple URLs that cause this behavior
Keywords: testcase-wanted
Whiteboard: [closeme 2010-12-15]

Comment 6

8 years ago
I use yahoo mail and gmail. So, those are my URLs for testing it. That's what most end users will likely use and see javascript eating CPU on a laptop. I don't know of any other URLs which can be used to trigger the same behavior.

Comment 7

8 years ago
Could you update to 3.6.13 and then see if the issue occurs with a new, empty profile:

Whiteboard: [closeme 2010-12-15] → [closeme 2011-01-31]
Version: unspecified → 1.9.1 Branch

Comment 8

8 years ago
Whiteboard closeme date been and gone, so marking as incomplete.

Please comment on/reopen this issue if it still occurs - and see comment 7 - thanks!
Last Resolved: 8 years ago
Resolution: --- → INCOMPLETE
Keywords: testcase-wanted
You need to log in before you can comment on or make changes to this bug.