In Node.js, the –max-old-space-size flag is used to increase the maximum heap memory limit for your application.
Usage Syntax
node --max-old-space-size=4096 your_script.js
This sets the max memory limit to 4096 MB (4 GB).
node --max-old-space-size=4096 server.js
In package.json:
"scripts": {
"start": "node --max-old-space-size=4096 index.js"
}
Or with build tools:
NODE_OPTIONS="--max-old-space-size=8192" npm run build
console.log(v8.getHeapStatistics());
Add this after:
const v8 = require('v8');
Work with our skilled Node developers to accelerate your project and boost its performance.
Hire Node.js Developers