Skip to content

Instantly share code, notes, and snippets.

@neuro-sys neuro-sys/index.js Secret
Created Feb 8, 2019

Embed
What would you like to do?
let buffer = '';
for (let i = 0; i < 1e6 * 512; i++) {
buffer += String.fromCharCode(65 + Math.floor(Math.random() * 26));
if (i % 1e6 === 0) {
console.log(Math.floor(process.memoryUsage().heapUsed / 1024 / 1024), 'MB heap is used');
}
}
$ node --max-old-space-size=128 index.js
4 'MB heap is used'
44 'MB heap is used'
81 'MB heap is used'
120 'MB heap is used'
159 'MB heap is used'
197 'MB heap is used'
235 'MB heap is used'
273 'MB heap is used'
311 'MB heap is used'
349 'MB heap is used'
387 'MB heap is used'
425 'MB heap is used'
463 'MB heap is used'
501 'MB heap is used'
539 'MB heap is used'
577 'MB heap is used'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.