简体   繁体   中英

Memory leaks when working with IEDriverServer and Selenium on C# with IE11

I am running C#-Selenium on IE11 on Windows 7/10. All the while when running the Script, the IE11 Memory keeps increasing until it reaches 1.5GB of Memory. Note I can't close or quit anything since I need my test to keep running. The Problem is IE11 keep getting bigger as the test progresses

In comparison, When running the same script with QTP, none of it happens. 32 bit WebDriver Version: 3.8 & 3.141

The Web Application itself is a propriety one Do you have any idea Where do I start looking to resolve the Issue?

Thanks

Tried reducing my code, sniffing for memory leaks

The issue might be that your test scripts actually don't close the browser(s).

I've experienced a bug in selenium IE that it doesn't close the browser with the .close, or .quite commants. That means it will open a lot of windows and that could cause the memory leaks..

Some sample code snippet of WebDriver and Web Browser initialization/closure process would have given us some hint why using IEDriverServer and IE11 memory keeps increasing until it reaches 1.5GB .

Perhaps as per best practices always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully as follows:

driver.quit() // Python
// or
driver.quit(); // Java
// or
driver.Quit(); // DotNet

You can find a detailed discussion in PhantomJS web driver stays in memory

Incase the IEDriverServer processes are still not destroyed and removed you may require to kill the processes from tasklist.

  • Python Solution( Cross Platform ):

     import os import psutil PROCNAME = "IEDriverServer" # or chromedriver or geckodriver for proc in psutil.process_iter(): # check whether the process name matches if proc.name() == PROCNAME: proc.kill() 

You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?

Additionally,

After a lot of searching I somewhat solve the issue by disabling the "Script Debugging (Internet Explorer)" in IE11 under Tools --> Options --> Advanced.

on my Selenium Code there's a listening to this ScriptExecuted events (which is a must in my code):

    firingDriver.ScriptExecuted += firingDriver_ScriptExecuted;

Can it be related?

So for now, I have no Idea why Disabling script debugging dramatically reduced the Memory Leaks. When running the same QTP scenario there is no Memory Leak.

and If anyone has an Idea, I would love to hear it

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM