1

I'm running a Selenium Standalone Server, version 2.25.0

I run a program in c# executing the driver by:

DesiredCapabilities capabilities = DesiredCapabilities.HtmlUnit();
capabilities.IsJavaScriptEnabled = false;
IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"), capabilities);

Then I collect some information via driver.FindElement(By.).

everything works fine.

After i executed all

I quit the driver by:

driver.Quit();

The test works fine. But when I take a look into the task-manager while executing I can see "java.exe" (the selenium server) grabbing memory and afterwards not releasing it.

How can i solve this problem? Any Ideas?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
bnz
  • 37
  • 1
  • 9

1 Answers1

1

hmm.... comparing to my code:

public class BaseSeleniumTest extends SeleneseTestBase {
    static WebDriver driver;



    @BeforeClass
    public static void firefoxSetUp() throws MalformedURLException {

          DesiredCapabilities capability = DesiredCapabilities.firefox();


        driver = new RemoteWebDriver(new URL("http://192.168.4.52:4444/wd/hub"), capability);




        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        driver.manage().window().setSize(new Dimension(1920, 1080));
    }
    @Before
    public void homePageRefresh() throws IOException {
        driver.get("login.base.url");
    }


    @AfterClass
    public static void closeFirefox(){
        driver.quit();
    }

.....
}

I do not have such memory issue. Grabbed memory was released. Could you provide the way you declare and initialize (creating instance) driver ?

enter image description here

Investigated a lil bit more: HtmlUnit appears to be leaking memory; what's the deal? Make sure (a) that you are using the latest version of HtmlUnit, and (b) that you are calling WebClient.closeAllWindows() when you are finished with your WebClient instance.

Taken from here

eugene.polschikov
  • 7,254
  • 2
  • 31
  • 44
  • Hey, you Code is Java isn't it? Well if im doing simple operations I don't have memory issues. But im Checking Several Links ond while crawling my site. My process java.exe is grown to 1.5 gigs ram... – bnz Oct 16 '12 at 12:57
  • yep. I'm using selenium+java. hmmm... seems very tricky issue( updated post with screen... – eugene.polschikov Oct 16 '12 at 13:33
  • Well I discovered, when I'm using a browser instead of the HtmlUnit I don't get the problem because the reserved RAM from the browser grows but in the end it gets closed correctly so it takes no effect on java.exe. – bnz Oct 16 '12 at 13:56
  • 1
    I create the Driver and I closed and quit it. I'm using the latest Version of selenium for c# . So I only can open the RemoteWebdriver and close this driver in the end. I think you mixing two different ways? Im using the HtmlUnit build in the Selenium. There are the only options: close or quit. – bnz Oct 16 '12 at 14:50
  • hmm... look through this set of issue. Suppose it be interesting to you. http://stackoverflow.com/questions/7535243/htmlunit-is-throwing-out-of-memory-and-maybe-leaking-memory http://www.seleniumwebdriver.com/google-selenium-webdriver/memory-leak-with-htmlunit-and-javascript-enabled/ http://stackoverflow.com/questions/9059773/htmlunit-selenium-within-production – eugene.polschikov Oct 16 '12 at 15:07
  • I'm using webdriver + java in my daily practice. But IMHO HtmlUnit somhow cause your memory leak issue – eugene.polschikov Oct 16 '12 at 15:08
  • IMHO too. But now tell me how can i close the driver correctly. I guess its because after a test a brwoser gets closed but not the server? When I'm running HtmlUnit its running directly via the server. But how to solve it? When i try to start the server again I'm getting heap mem errors :/. I'm using Webdriver too, but using it with the built in Remotewebdriver starting a HtmlUnit instead of an ff test. – bnz Oct 16 '12 at 15:34