Trying to understand the creation of Casper.page instance

26 views
Skip to first unread message

Kane Ho

unread,
Mar 4, 2016, 1:01:50 AM3/4/16
to CasperJS
Hi all,

I am studying the code recently and I found an interesting piece of code when instantiating WebPage instance in Casper.

if (!utils.isWebPage(this.page)) {
    this.page = this.mainPage = utils.isWebPage(this.options.page) ? this.options.page : createPage(this);
}

I am just wondering why ONLY when the page is not a web page, we should instantiate the new page instance?
Besides, I fill that we should always close the previous page instance before dereferencing it to avoid potential memory leak.
If PhantomJS didn't recycle this unused page properly, we may end up using a lot of memory if there are thousands of tests in a suite.

Please correct me if I missed anything.

Thanks!

Regards,
Kane

Ken

unread,
May 28, 2017, 10:45:48 PM5/28/17
to CasperJS
Hi Kane, this looks like an interesting observation. Not sure if the current logic remains the same. Have you shared with the CasperJS GitHub issues page?

Kane Ho

unread,
May 29, 2017, 12:39:46 AM5/29/17
to casp...@googlegroups.com
The logic didn't change, it is still here:

I didn't post it on the issues page as I remember the recommendation is to ask questions here...

--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs
 
You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to a topic in the Google Groups "CasperJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/casperjs/ePwfUqF8pRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to casperjs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kane HO

Tel: +1 (425) 753-7758Facebook: kaneho
Twitter: @kanehohk

Ken Soh | Tebel

unread,
May 29, 2017, 4:23:52 PM5/29/17
to casp...@googlegroups.com
Thanks Kane... Oh yes I think one of the maintainers suggested to use the group for an issue I saw in March. Let me just post a new issue on your behalf and copy you on the issues page. Since this was posted here for a year and no response, and it is an interesting observation maintainers can relook at to review.

Kind Regards,
Reply all
Reply to author
Forward
0 new messages