Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 443 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to increase nodejs default memory?

#1
On Server startup exporting 2GB(Approximately) data from mongodb to redis,then getting error as `FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory`.

Then started server with this command `node --max-old-space-size=4076 server.js` and works fine. But needs to configure in nodejs applicaton so that node server always starts with 4gb memory. Please help me how to fix this?
Thanks.
Reply

#2
one option: npm start scripts

[To see links please register here]


These are added to your package.json under the "scripts" section


{
//other package.json stuff

"scripts":{
"start": "node --max-old-space-size=4076 server.js"
}

}

then to run it call `npm start` instead of typing in node + args + execution point.

Note: if you name it something other than start, `npm run [yourScriptNameHere]` will be the command to run it

This is a better option than trying to reconfigure node to use 4gb by default (don't even know if its possible tbh). It makes your configuration portable by using the baked in methods as it stands and allows others who encounter your code in the future to understand this is a need.
Reply

#3
You can also set [`NODE_OPTIONS`](

[To see links please register here]

) when running an npm script rather than `node` itself:

"scripts": {
"start": "NODE_OPTIONS=--max-old-space-size=4096 serve",
},
Reply

#4
There are two ways to resolve this, First way is to set memory size explicitly for your application, already answered above. And the other way is to set memory size globally for node - This is done by creating an **Environment variable**, with

variable name=NODE_OPTIONS

and

variable value=--max-old-space-size=4096
Reply

#5
node --max-old-space-size=8192 some-script.js

- Where *SomeScript* is the file name that you want to execute using
node.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through