SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.5k stars 8.15k forks source link

Out of heap space on 104mb FF profile Selenium 3.0.1 #3372

Closed apr-1985 closed 4 years ago

apr-1985 commented 7 years ago

OS: Windows 7 running Standalone Jar file Selenium Version: 3.0.1 Browser: Firefox with Gecko Driver Browser Version: 47.0.1

Background -

I am running the Selenium Standalone JAR file on windows 7 32bit boxes, my tests then connect to these servers using webdriver.Remote in the python binding. All through Selenium 2 this has worked fine, but I am now getting an error when running FireFox from with Selenium 3.

I am using this line to start the Selenium Server (all on a single line): java -Xmx1600m -Dwebdriver.firefox.profile="webdriver" -Dwebdriver.ie.driver="c:/selenium/IEDriverServer.exe" -Dwebdriver.gecko.driver="c:/selenium/geckodriver.exe" -Dwebdriver.chrome.driver="c:/selenium/chromedriver.exe" -jar C:\selenium\selenium-server-standalone-3.0.1.jar

Expected Behavior -

When using the the -Dwebdriver.firefox.profile="webdriver" option on the standalone server I would expect Selenium to launch FireFox using that profile (it has done in all 2.X versions I have used) The profile is a total of 104mb in size.

Actual Behavior -

When trying to launch the FireFox browser Selenium throws: java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException

And eventually a WARN - Exception: Java heap space

If I remove the -Dwebdriver.firefox.profile="webdriver" option when starting the standalone server then Selenium starts a FireFox browser with a default profile.

Steps to reproduce -

Log attached selenium_log.docx

apr-1985 commented 7 years ago

I have managed to get the profile loading by cutting down the profile size down to 50mb, and keeping the heap size at 1500mb. This is a definitely a Selenium bug in 3.0.1 as in Selenium 2 I used to run my Windows Selenium servers with 1GB of RAM, standard Java heap and the full profile. Changing only the Selenium Jar file to 3.0.1 I have had to increase the servers to 4GB RAM, the Java heap to 1500mb and cut my profile.

Please could you advise what has happened in Selenium 3 to require this large resource increase?

shs96c commented 7 years ago

The remote webdriver attempts to determine whether or not the remote end speaks the w3c protocol or the json wire protocol from 2.x. In order to do this, it sends an initial request for a new session with the options encoded for both the old and the new parameters. This means that the amount of memory required to send a profile has effectively doubled.

AlehVasilyeu commented 7 years ago

Same issue reproduced in my case:

Selenium: 3.0.1 Firefox: 51.0.1 Custom profile size: ~38 mb Profile was set through webdriver.firefox.profile option.

It's understandable that amount of memory increased for storing profile. And memory not free after tests passed...

Selenium server allocates about 1.2 gb of memory and keep it.

Maybe here is exist some workaround? How do not transfer profile information? I don't need it in responses for session details.

diemol commented 4 years ago

Yes, there is a bug in Grid 3.x where things sent over the wire (profiles, uploading a file...) consume the heap size quickly. The workaround is to increase the heap size, which we understand is not optimal.

In any case, Grid 3.x is not under development anymore. Grid 4 is an entirely new code base, could you please try it from https://www.selenium.dev/downloads/ and open a new issue in case you still see the same behavior.