Created
September 3, 2015 20:47
-
-
Save gobwas/9837fa33bd44106fcd41 to your computer and use it in GitHub Desktop.
Alloc error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bigInt = 1000000000; | |
console.log(process.argv); | |
function asBuf() { | |
var buf = new Buffer(""); | |
for (var i = 0; i < bigInt; i++) { | |
if (i % 10000 == 0) console.log(process.memoryUsage()['rss'] / 1024 / 1024 + 'mb'); | |
buf = Buffer.concat([buf, new Buffer("a")]); | |
} | |
} | |
function asArr() { | |
var arr = []; | |
for (var i = 0; i < bigInt; i++) { | |
if (i % 10000 == 0) console.log(process.memoryUsage()['rss'] / 1024 / 1024 + 'mb'); | |
arr.push("a"); | |
} | |
} | |
if (process.argv[2] == '--buffer') { asBuf(); } else { asArr(); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment