Increasing Memory/Heap Size of Node.js

By default, Node sets a memory/heap size limit that is under 2 GB. This default can be changed by passing in a value in megabytes (MB) when starting a Node server using the following option:

--max_old_space_size=<heapSizeInMB>

Thus, the command below will start a server with a heap size of up to 4 GB.

node --max_old_space_size=4000 scriptThatStartsServer.js

Written by

Software Developer. Focused. Determined. Unstoppable.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store