Skip to content

Instantly share code, notes, and snippets.

@SET001
Created September 6, 2020 13:18
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 SET001/2ea8f08349565ccfe36c65ea5b45d06d to your computer and use it in GitHub Desktop.
Save SET001/2ea8f08349565ccfe36c65ea5b45d06d to your computer and use it in GitHub Desktop.
eat all memory in node.js
const chunkSize = 1000
const bufs = []
try {
do {
bufs.push(Buffer.alloc(chunkSize * 1024 * 1024, 'x'))
} while (true)
} catch (e) {
console.log('stopping and ', Math.round(process.memoryUsage().rss / (1024 * 1024)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment