Skip to content

Instantly share code, notes, and snippets.

@neuro-sys
Created February 8, 2019 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuro-sys/cf6a7724b5f4c2257a19e67d6eb1c44a to your computer and use it in GitHub Desktop.
Save neuro-sys/cf6a7724b5f4c2257a19e67d6eb1c44a to your computer and use it in GitHub Desktop.
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