I want to know selenium with firefox question,
I used Firefox version 56.0.2,selenium3.5.1,and geckodriver 0.19.1,server ubuntu(x64) os,firefox --headless mode
I find when I run my app for a long time, the firefox memory will increase a lot, such 400MB or more, and when I let firefox open about:blank
, the memory don not decrease
I want to know how to decrease the firefox memory (do not kill the firefox process), only use the selenium to control firefox or start firefox with some config
I want to open "about:blank" or other URL to reduce memory,but I find it doesn't work;

- 183,867
- 41
- 278
- 352

- 51
- 1
- 2
1 Answers
No,Selenium itself doesn't uses any memory. It's the WebDriver and Web Browser processes which consumes the memory. For an example when you create a new instance of any WebDriver variant to start a relevant Web Browsing Session, both the process consumes memory.
Now the different Browser Client variants will follow different and distinct methods and style to initiate
, manage
and teardown
the browser internal process. So memory consumption will be different for the different browsers.
Answering your questions :
When I run my app for a long time, the firefox memory will increase a lot : In-coarse of handling a active browsing session, the browser binary have to keep track a lot of memory (stack memory / heap memory) resources time to time. Hence memory consumption can go up/down depending on situation.
I want to know how to decrease the firefox memory : No, you have no control over the memory consumption of a browser.
Solution
Web Browsers have evolved a lot recently. Each of the Web Browser variants e.g. Mozilla, Chrome and Internet Explorer are continuously working on a more momery efficient browser process. You can take the following steps for your Automated Tests to consume the optimum memory :
- Keep the JDK Version updated to the latest versions as each release aims towards optimum memory utilization.
- Keep the Selenium Version updated to the latest versions as each release aims towards better memory management.
- Keep the WebDriver Version updated to the latest versions as each release aims towards better memory management.
- Keep the Web Browser Version updated to the latest versions as each release aims towards better memory utilization.
If the base version of your Web Browser is too older, you may consider to uninstall the Web Browser through Revo Uninstaller and install a recent stable and GA version of the Web Browser .
Use CCleaner tool before and after your Test Execution to wipe off the OS system chores.
Perform the Test Execution in an isolated system free from Manual Intervention
Keep the Test System within the Test Lab well equipped with the Hardware Requirements to execute the Test Suites.

- 183,867
- 41
- 278
- 352
-
I want to know when i use Selenium to open many urls,such as faceook,google or more; at last ,I open about:config the page,I found the firefox memory doesn't reduce,i feel that the page is blank,the memory should be reduced,but it doen't work ,why? – tjxy573 Jan 31 '18 at 08:50
-
@tjxy573 As an user we don't have a control over how memory handling is carried out by the _OS_ and _Browser Binary_ combination.So IMO, there is no point in validating/observing memory stats until and unless it is part of your _Tests_ . But if you have a valid point/observation you can raise the issue with the _Browser Vendors_ and you may be rewarded too. – undetected Selenium Jan 31 '18 at 08:55
-
1at last,I resolve the question by myself, actually this is bug of firefox for long long time,so I do not use firefox,I used chrome,and I found the memory of chrome is smaller than firefox ,especially in headless,and very stable;I can use 1G memory can run my app,but is will cost 2G if I use firefox;than you! – tjxy573 Feb 05 '18 at 07:22
-
4Too much buzzwords, too little to no meaning. The bullets under "solution" are all devoid of meaning and/or outright false. – ivan_pozdeev Nov 23 '18 at 01:04