Skip to content

Instantly share code, notes, and snippets.

@aizatto
Created September 27, 2017 19:50
Show Gist options
  • Save aizatto/79c090f23849952f2dcfd915d7ce5594 to your computer and use it in GitHub Desktop.
Save aizatto/79c090f23849952f2dcfd915d7ce5594 to your computer and use it in GitHub Desktop.
allocation memory in node till it runs out
// 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