piscinajs / piscina

A fast, efficient Node.js Worker Thread Pool implementation

Home Page:https://piscinajs.github.io/piscina/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak on worker run

hohooio823 opened this issue · comments

I'm using Piscina to run puppeteer instances in parallel in next js. I've been noticing that the size of the node process is getting out of hand, and after adding a few console.log(memoryUsage().rss / 1024 / 1024 / 1024);, I've found that the reason for this is that immediately after the pool starts running 25 Mb is increased in the node process ram usage. As you can imagine, with multiple workers running, It quickly gets out of hand.
I run abortController.abort() after the worker is done, but the memory usage stays the same.
I appreciate your help :)

I solved It 😁 I was initializing a different pool every time the puppeteer instance is supposed to run.
Now, I'm using the same pool and the memory usage is perfect.
Hopefully, this spares somebody's head from spinning around in case they face a similar issue.