Controlling Nodejs RAM Usage

When starting the node app, use the --max_old_space_size option.

This variable is in megabytes. This is more or less controlling how much memory can be used for garbage collection. It is recommended to set it to 3/4 of the available RAM on your machine. It's useful to try matching your dev and production environment!

Example: node --max_old_space_size=512 app_to_start.js

Alternatively, you can also use the NODE_OPTIONS environment variable.

Source from the nodejs documentation.