Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux phantomjs-巨大的内存使用_Linux_Selenium_Phantomjs - Fatal编程技术网

Linux phantomjs-巨大的内存使用

Linux phantomjs-巨大的内存使用,linux,selenium,phantomjs,Linux,Selenium,Phantomjs,我正在linux虚拟机上使用selenium和phantom js web驱动程序。 由于幻影的每个实例似乎都消耗了太多内存,在三个实例之后,虚拟机崩溃,我必须重新启动机器 有没有办法保证虚拟机不会崩溃或减少phantom的巨大内存使用 service_args = [ '--ignore-ssl-errors=true', '--proxy=' + proxyIP + ':' + str(proxyPort),

我正在linux虚拟机上使用selenium和phantom js web驱动程序。 由于幻影的每个实例似乎都消耗了太多内存,在三个实例之后,虚拟机崩溃,我必须重新启动机器

有没有办法保证虚拟机不会崩溃或减少phantom的巨大内存使用

service_args = [
                    '--ignore-ssl-errors=true',
                    '--proxy=' + proxyIP + ':' + str(proxyPort),
                    '--proxy-type=http',
                    ]
self.browser = Browser(driver_name="phantomjs", service_args=service_args)

经过研究,我发现phantomjs会导致内存泄漏,据我所知,最好的解决方案是每隔一段时间检查phantomjs的内存使用情况,如果超过阈值,则关闭phantomjs并重新打开。这是目前我能找到的解决问题的最佳解决方案。

我也遇到了同样的问题,并决定像您一样实施,在完成PhantomJS驱动程序后释放它(及其过程),在我再次需要它时重新启动它。是的,这是一种丑陋的解决方案,但它就是这样:)