PhantomJS web driver stays in memory

扶醉桌前 提交于 2019-12-17 02:51:36

问题


I am instantiating the PhantomJSDriver in C# with this code:

Driver = new PhantomJSDriver();

And cleaning it up with this:

Driver.Dispose();
Driver = null;

Should the process exit or stay in memory? If it is supposed to stay in memory, visible in the Windows 7 task manager, can I kill it programmatically? Should I?


回答1:


Answering straight, Driver.Dispose(); shouldn't be used to clean up the WebDriver instance. For a proper cleanup we must be using Driver.Quit();.

  1. Driver.Dispose();: I think got deprecated.
  2. Driver.Close();: It is used to close the current page or the browser (if it is the only page/tab) which is having the focus.
  3. Driver.Quit();: It is used to call the /shutdown endpoint and subsequently the web driver instance is destroyed completely closing all the pages/tabs/windows.

Hence calling the Driver.Quit() method is the only way to guarantee that sessions are properly terminated.

In this discussion you can find a detailed analysis on Driver.Dispose();, Driver.Close(); and Driver.Quit();



来源:https://stackoverflow.com/questions/45985008/phantomjs-web-driver-stays-in-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!