Skip to content

Instantly share code, notes, and snippets.

@daipeihust
Created September 8, 2020 00:26
Show Gist options
  • Save daipeihust/9d14243d65f1484a3d524786f53dc8e3 to your computer and use it in GitHub Desktop.
Save daipeihust/9d14243d65f1484a3d524786f53dc8e3 to your computer and use it in GitHub Desktop.
Memory leak
var theThing = null;
var replaceThing = function () {
var originalThing = theThing;
var unused = function () {
if (originalThing)
console.log("hi");
};
theThing = {
longStr: new Array(1000000).join('*'),
someMethod: function () {
console.log(someMessage);
}
};
};
setInterval(replaceThing, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment