Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configuration max old space size in Nodejs

Im a newbie in nodejs and mongodb. I have a problem when i read about 100000 records from my mongodb in nodejs application. When I try to get 100000 records, I got this error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

I search google and everyone said that configure max old space size parameter because v8 engine have about 1,9Gb heap memmory.

My point is, I run my app by eclispe, and i dont know how to configure max-old-space-size parameter.

Can anybody give a hint?

Thank you so much!

ps: my english is bad so if you cannot understand my question, it's fine.

like image 550
user1697646 Avatar asked Dec 04 '15 02:12

user1697646


People also ask

How do you increase Node max old space size?

If you want to increase the max memory for Node you can use --max_old_space_size option. You should set this with NODE_OPTIONS environment variable.

What is the default V8 memory limit on 32-bit system?

Currently, by default v8 has a memory limit of 512mb on 32-bit and 1gb on 64-bit systems. You can raise the limit by setting --max-old-space-size to a maximum of ~1gb for 32-bit and ~1.7gb for 64-bit systems.

How do I stop JavaScript heap out of memory?

To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Alternatively, you can also set the memory limit for your entire environment using a configuration file.


1 Answers

Use node --max_old_space_size=5000 yourapp.js to allow 5000 mb. Look in your eclipse launch settings for command-line parameters, where you can add this.

However, as the comments say, you should reconsider loading this into memory, and stream it to the client instead.

like image 183
ZachB Avatar answered Oct 08 '22 03:10

ZachB