如何减少phantomjs的内存消耗? [英] How to reduce phantomjs memory consumption?

查看:20
本文介绍了如何减少phantomjs的内存消耗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 casperjs 的 phantomjs 来运行多个测试,看起来 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"?

推荐答案

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

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

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

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

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

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.

:)

这篇关于如何减少phantomjs的内存消耗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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