We have developed a maven-based java project and which replacing emails in bulk but after a certain time browser goes to "Out of memory error".
Initially, we were doing it in the Chrome browser but later on, some research used Microsoft Edge due to less memory consumption. In selenium, the script browser navigates 6 or 7 pages.
Running on 12GB of RAM system and eclipse takes normally around 900 MB and MS-Edge taking around 1600 MB After a certain time program crashes due to browser memory.
CodePudding user response:
you could try to play with java xmx and xms parameters with big values when launch your java app to solve the issue. To have a deeper analysis, you could use a tool like Jprofiler or Arthas to probe your application stack.
CodePudding user response:
As discussed in comments try it in headless
mode. This is not an solution but I cannot put entire this thing as comment.
Maven dependency: Use selenium 4
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-7</version>
</dependency>
Launch in headless
mode:
/*Edge options*/
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("--headless");
/* Initialize and adding chrome options to the driver. */
driver = new EdgeDriver(edgeOptions);
driver.manage().deleteAllCookies();
driver.get("https://www.google.com");
I am not sure you are using cucumber
or TestNG
if you are not quitting the browser at end of the test then please quit
it.
driver.quit();
If you are still seeing issue then run below command after driver.quit();
driver.quit();
Runtime.getRuntime().exec("taskkill /F /IM EdgeDriver.exe");
Running on 12GB of RAM system and eclipse takes normally around 900 MB and MS-Edge taking around 1600 MB After a certain time program crashes due to browser memory.
Close the any other edge browsers which was opened manually before run.