1

I have a slightly unexpected result for me with the code below. Each iteration adds approximately 1% to the CPU load. At the moment when I run this test, I have about 5% CPU load, and after exiting the loop for 100 seconds, the CPU load is 60%. But all instances of chromedriver are closed! Why is this happening?

import org.junit.Test;
import org.openqa.selenium.chrome.ChromeDriver;

public class myclass {
    @Test
    public static void test() throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", "chromedriver");
        for (int i=0;i<50;i++){
            ChromeDriver driver=new ChromeDriver();           
            driver.quit();                
        }
        Thread.sleep(100000);
    }

    public static void main(String[] args) throws Exception {
        test();       
    }
}
void000
  • 11
  • 2
  • Maybe a Memory leak with ChromeDriver. What are you trying to achieve here? I think it's not a good idea to create many Driver instances. – Marcel Apr 21 '20 at 13:40
  • What is using CPU? Java or Chrome? – Taylor Apr 21 '20 at 13:46
  • The CPU is i7 6700HQ. Chrome 81.0.4044.113 + ChromeDriver 81.0.4044.69 + Selenium Java 4.0.0-alpha-4. I used several different combinations on my CPU, but the result is the same. – void000 Apr 21 '20 at 14:06
  • Probably your solution is here https://stackoverflow.com/questions/21320837/release-selenium-chromedriver-exe-from-memory – Alexey R. Apr 21 '20 at 14:07
  • I have reasons to create multiple instances. For example, you can change the user agent only before creating a new instance of the web driver. – void000 Apr 21 '20 at 14:07

0 Answers0