我运行在远程的webdriver模式phantomjs与phantomjs --webdriver 8910
,然后让使用硒python绑定多页的东西,如:使用selenium webdriver限制phantomjs的内存使用情况?
wd = webdriver.PhantomJS(port=8910)
for url in big_url_list:
wd.get(url)
# do something here, e.g. wd.save_screenshot or print wd.page_source
wd.quit()
的wd.quit()
显得无能为力。用top监视进程表明,随着更多页面的检索,phantomjs进程的内存使用量不断增加。如果我重新启动phantomjs进程,那么内存使用量会降低,并开始稳定爬升。
close method mentioned in the phantomjs docs听起来很有希望,但我看不到通过WebDriver protocol调用该方法的任何方法。
有没有(i)一种方法可以在进行多次请求时保持幻像的内存使用量,或者(ii)监控和定期重启phantomjs进程的可靠方法,使内存永不失控?