I am trying to increase memory limit in node, so I added an environment variable
it does not work not sure why I also tried it with capital letters here is how I test it
const maxHeapSz = require('v8').getHeapStatistics().heap_size_limit;
const maxHeapSz_GB = (maxHeapSz / 1024 ** 3).toFixed(1);
console.log(`${maxHeapSz_GB}GB`);
I keep gettin 2GB, I'm trying to get 8GB
I appreciate any help
CodePudding user response:
You can use
node --max-old-space-size=8192 app.js
It's work for me!
Result:
node --max-old-space-size=8192 test.js
8.0GB
CodePudding user response:
The actual memory that is consumed by the application (in the form of objects in the JavaScript heap) is represented by heapUsed field in process.memoryUsage() API.
You can check for more information here. This article also shows methods to increase the maximum heap size.