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

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

问题描述

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

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

Driver = new PhantomJSDriver();

并用这个清理它:

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端点,随后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.

在这个讨论中,你可以找到Driver.Dispose();Driver.Close();Driver.Quit();

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

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