How to Increase Node.js Memory Allocation

Last updated: February 9, 2026

Setup Memory Allocation

  1. Locate your Node.js application's startup configuration or deployment environment

  2. Set the environment variable NODE_OPTIONS with the desired memory allocation:

    NODE_OPTIONS=--max_old_space_size=<memory-in-mb>
  3. Replace <memory-in-mb> with your desired memory limit in megabytes. For example:

    NODE_OPTIONS=--max_old_space_size=4096

    This 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