baudehlo / node-phantom-simple

Simple bridge to phantomjs for Node
MIT License
201 stars 70 forks source link

Memory leak on creating multiple browsers? #117

Open laggingreflex opened 8 years ago

laggingreflex commented 8 years ago

I'm creating lots of browser instances with driver.create() in a batch (~10 or so instances at once) and even though I'm exiting them all with browser.exit() before creating another batch, I'm seeing huge spikes of memory and eventually the node process exits giving memory allocation error (in pm2).

I measured by simply creating new instances and calculating increase in process.memoryUsage().heapUsed and it shows ~1-3% increase on every instance, eventually building up ~45% in just 20 iterations (create=>exit=>create).

Could this be a bug in the library or is this bound to happen when you create so many instances?

edit: added a test

puzrin commented 8 years ago

v8 GC strategy depends on amount of available memory. Simple check of occupied process memory can not say that it's a real memory leak. Because node's memory really increase to some point after run.

May be, you really have few of memory, and forked phantoms leave nothing for node.js?