PhantomJS Web驱动程序保留在内存中 [英] PhantomJS web driver stays in memory

查看:92
本文介绍了PhantomJS Web驱动程序保留在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在C#中实例化PhantomJSDriver:

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

Driver = new PhantomJSDriver();

并使用以下命令对其进行清理:

And cleaning it up with this:

Driver.Dispose();
Driver = null;

该进程应该退出还是留在内存中?如果应该保留在Windows 7任务管理器中可见的内存中,我可以通过编程方式将其杀死吗?我应该吗?

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?

推荐答案

直接回答,不应使用Driver.Dispose();清理WebDriver实例.为了进行适当的清理,我们必须使用Driver.Quit();.

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();:我认为已弃用.
  2. Driver.Close();:用于关闭当前页面或具有焦点的浏览器(如果是唯一的页面/选项卡).
  3. Driver.Quit();:用于调用/shutdown endpoint,随后破坏了Web驱动程序实例,从而完全关闭了所有页面/选项卡/窗口.
  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.

因此,调用 Driver.Quit() 方法是确保正确终止会话的唯一方法.

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

在此 discussion 中,您可以找到详细的分析在Driver.Dispose();Driver.Close();Driver.Quit();

这篇关于PhantomJS Web驱动程序保留在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆