How to Increase Node.js Memory Allocation
Last updated: February 9, 2026
Setup Memory Allocation
Locate your Node.js application's startup configuration or deployment environment
Set the environment variable
NODE_OPTIONSwith the desired memory allocation:NODE_OPTIONS=--max_old_space_size=<memory-in-mb>Replace
<memory-in-mb>with your desired memory limit in megabytes. For example:NODE_OPTIONS=--max_old_space_size=4096This would set the memory limit to 4GB
Usage
The memory allocation setting helps prevent JavaScript heap out of memory errors in your Node.js application. If you see error messages like "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory", you may need to increase your memory allocation.
Choose an appropriate memory value based on:
Your application's actual memory requirements
Available system resources
Deployment environment constraints