Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

phantomjs doesn't release memory #207

Open
xesina opened this issue May 23, 2015 · 12 comments
Open

phantomjs doesn't release memory #207

xesina opened this issue May 23, 2015 · 12 comments

Comments

@xesina
Copy link

xesina commented May 23, 2015

I'm using a vps with 2G of ram with one project in pyspider, after a few minutes of crawling phantoms is filling the memory and won't release even after stopping the project.

@binux
Copy link
Owner

binux commented May 23, 2015

What do you mean of "stop the project"? stop pyspider or via webui?
What's the version of phantomjs you are using?

@xesina
Copy link
Author

xesina commented May 23, 2015

stop the project from web ui.
phantomjs --version
1.9.8

@binux
Copy link
Owner

binux commented May 23, 2015

Stop projects would not make phantomjs release memory.
I have did things to release resources after request finished. But there is no certain way to make sure it did (google "phantomjs memory").

I have a phantomjs instance with crawl rate of 5 pages per minute, it cost ~500MB. And my solution is restart it every hour.

@xesina
Copy link
Author

xesina commented May 23, 2015

how can i restart phantom?
thanks, I will check phantomjs_fetcher.js.

@binux
Copy link
Owner

binux commented May 23, 2015

if you are running pyspider use command pyspider: ps && kill

@xesina
Copy link
Author

xesina commented May 23, 2015

As you said in js file, there is a memory leak that resolved by :
page.settings.loadImages = true;

@binux
Copy link
Owner

binux commented May 24, 2015

Does that work?
I does not believe that a normal function can lead to memory leak and not fixed!

@xesina
Copy link
Author

xesina commented May 24, 2015

Yes, after changing that parameter its just working fine!

@binux
Copy link
Owner

binux commented May 25, 2015

I will make it true by default.

@laoyuan
Copy link

laoyuan commented Jun 6, 2015

but load Images take too much time

@laoyuan
Copy link

laoyuan commented Jun 6, 2015

@binux what's the proper posture to restart PhantomJS every hour?
I run it by: nohup pyspider -c /usr/local/etc/pyspider.json phantomjs &

@binux
Copy link
Owner

binux commented Jun 6, 2015

manage instance with some sort of Process Control System like supervisord.org, then just kill it every hour.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants