-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_memory_allocation_prevent_fatal.js
More file actions
21 lines (20 loc) · 1.17 KB
/
example_memory_allocation_prevent_fatal.js
File metadata and controls
21 lines (20 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// # Plain Ol' Node
// node --max-old-space-size=1024 app.js # increase to 1gb
// node --max-old-space-size=2048 app.js # increase to 2gb
// node --max-old-space-size=3072 app.js # increase to 3gb
// node --max-old-space-size=4096 app.js # increase to 4gb
// node --max-old-space-size=5120 app.js # increase to 5gb
// node --max-old-space-size=6144 app.js # increase to 6gb
// # For pm2
// pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb
// pm2 start app.js --node-args="--max-old-space-size=2048" # increase to 2gb
// pm2 start app.js --node-args="--max-old-space-size=3072" # increase to 3gb
// pm2 start app.js --node-args="--max-old-space-size=4096" # increase to 4gb
// pm2 start app.js --node-args="--max-old-space-size=5120" # increase to 5gb
// pm2 start app.js --node-args="--max-old-space-size=6144" # increase to 6gb
let arr = Array(1e8).fill("TehranJS");
let arr2 = Array(1e8).fill("TehranJS");
arr.reverse();
arr2.reverse();
const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`The script uses approximately ${used} MB`);