如何减少phantomjs内存消耗?

发布于 2024-12-22 23:35:05 字数 111 浏览 4 评论 0原文

我使用 phantomjs 和 casperjs 来运行多个测试,看起来 PhantomJS 的每个实例都占用约 106M 的 RAM。可以减少这个数额吗?有没有一种简单的方法可以在多个“选项卡”中运行测试?

I'm using phantomjs with casperjs to run multiple tests and it looks like each instance of PhantomJS takes ~106M of RAM. Is it possible to reduce that amount? Is there a simple way to run tests in multiple "tabs"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2024-12-29 23:35:05

编辑: 正如@newfurniturey 所指出的,release 现已弃用。我们必须使用close
http://phantomjs.org/api/webpage/method/close.html

不知道这是否有帮助,但是 release 函数可能是一个很好的尾巴:
http://phantomjs.org/api/webpage/method/release.html

释放与此页面关联的内存堆。不要使用该页面
调用此后的实例。

由于某些技术限制,网页对象可能无法
完全垃圾收集。当同样的情况时,经常会遇到这种情况
对象被一遍又一遍地使用。 调用此函数可能会停止增加堆分配。

:)

Edit: As pointed by @newfurniturey, release is now deprecated. We must use close:
http://phantomjs.org/api/webpage/method/close.html

Don't know if that helps, but the release function could be a good tail :
http://phantomjs.org/api/webpage/method/release.html

Releases memory heap associated with this page. Do not use the page
instance after calling this.

Due to some technical limitation, the web page object might not be
completely garbage collected. This is often encountered when the same
object is used over and over again. Calling this function may stop the increasing heap allocation.

:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文