- save below code in nodejs_default_memory_check.js,
- execute it -
node nodejs_default_memory_check.js
. You can see this script fails and thats default RAM limit of NodeJS. Plz check screenshot in below comment. In Latest NodeJS versions default RAM is 4GB (still on the basis of your hardware and system OS, RAM will differ) - use max-old-space-size option if you want to increase memory limit. It accepts value in MB. In this example we are setting 8GB RAM
node --max-old-space-size=8192 nodejs_default_memory_check.js
function allocateMemory(size) {
// Simulate allocation of bytes
const numbers = size / 8;
const arr = [];
arr.length = numbers;