Created
September 27, 2017 19:50
-
-
Save aizatto/79c090f23849952f2dcfd915d7ce5594 to your computer and use it in GitHub Desktop.
allocation memory in node till it runs out
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
// strict | |
function mb(bytes) { | |
return Math.floor(bytes / 1024 / 1024 ); | |
} | |
function print() { | |
const memoryUsage = process.memoryUsage(); | |
console.log({ | |
rss: mb(memoryUsage.rss), | |
heapTotal: mb(memoryUsage.heapTotal), | |
heapUsed: mb(memoryUsage.heapUsed) | |
}); | |
} | |
var arr = []; | |
print(); | |
while (true) { | |
arr.push(Array(1e6).fill("some string")); | |
print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment