How to reduce PhantomJS's CPU and memory usage?

点点圈 提交于 2020-01-22 18:51:28

问题


I'm using PhantomJS via Python's webdriver lib. It eats lots of RAM and CPU, and it's an issue because I'd like to run as many instances as it's possible.

Some google'ing didn't give me anything helpful. So I'll ask directly:

  1. Does the size matter? If I set driver.set_window_size(1280, 1024), will it eat more memory than 1024x768?

  2. Is there any option in the source code which can be turned off without real issues and which lead to significant memory usage reduce? Yes I still need images and CSS and JS loading and applying, but I can get rid of some other features... For example, I can turn off caching (and load all media files every time). Yes, I do need to speed it up and make it less greedy and I'm ready to re-compile it... Any ideas here?

Thanks a lot!


回答1:


I assume you call phantomjs once for every rendering job. This creates a new phantomjs process every time. You could try batching as many as you could in the one js script and call phantomjs once for the whole batch.



来源:https://stackoverflow.com/questions/22424461/how-to-reduce-phantomjss-cpu-and-memory-usage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!