Skip to content

Instantly share code, notes, and snippets.

@0xsonu
Last active March 1, 2022 13:15
Show Gist options
  • Save 0xsonu/2ac62f12324dae84f3b5d41daad573f6 to your computer and use it in GitHub Desktop.
Save 0xsonu/2ac62f12324dae84f3b5d41daad573f6 to your computer and use it in GitHub Desktop.
NodeJS Hacks

manage heap size of node procsess

to see current allocated size for node env. run this command in terminal node -e 'console.log(v8.getHeapStatistics().heap_size_limit/(1024*1024))'

to set/increase heap size run this command in terminal

Windows

From the control panel go to System → Advanced system settings → Environment Variables → New (user or system) image

Or this can be done in PowerShell with:

$env:NODE_OPTIONS="--max-old-space-size=8192" You can also increase this number, if necessary. We've seen folks need to increase this up to 14 GB for some larger projects!

Linux/macOS

export NODE_OPTIONS=--max-old-space-size=8192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment