FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory when processing large files using PM2

Viewed 192

I have a pretty huge database, at around 2 million records and I have created a paginated API in NodeJs + Express in which I query the database.

I am starting my app using PM2 with the command:

pm2 start app.js --node-args="--max_old_space_size=8192"

But still, receiving the same error.

Which is a good way to not receive this anymore ? My server has 24GB of RAM, I guess I can increase more, but I tested with 4,6 and now 8GB and nothing work.

Is there an optimization that can be done ?!

0 Answers
Related