Last active
March 21, 2022 15:50
-
-
Save mcollina/1a56c2a7fc1c8da7f74729535b4091bf to your computer and use it in GitHub Desktop.
Error keep things from collecting
This file contains hidden or 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
// Taken from https://twitter.com/robpalmer2/status/1505881530379419652?s=20&t=rNQb26Rwq0fddQHbhalpbw | |
function test() { | |
const lotsOfMemory = new Uint8Array(1000 * 1000 * 100); | |
function retains() { lotsOfMemory } | |
const someNumber = Math.random(); | |
setInterval(() => { | |
console.log(someNumber); | |
}, 1000); | |
} | |
test(); // See 100MB forever in heap inspector |
This file contains hidden or 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
let error; | |
function test() { | |
const data = new Array(1000000).fill(0); | |
return () => { | |
error = new Error(); | |
data.push(0); | |
} | |
} | |
test()(); | |
setTimeout(() => { | |
console.log(error.stack); | |
}, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment