Created
February 17, 2019 17:32
-
-
Save tjcrowder/8a6993d8c8cd204c21667c3856f01ae1 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | |
<title>[[HomeObject]] Check</title> | |
</head> | |
<body> | |
<input type="button" id="release" value="Release Objects"> | |
<input type="button" id="show-count" value="Show Function Count"> | |
<script type="module"> | |
let objects = []; | |
let functions = []; | |
for (let n = 0; n < 100000; ++n) { | |
objects[n] = { | |
name: `obj${n}`, | |
[Symbol.toStringTag]: "ABC", // Make it easier to find them in snapshots in Chrome | |
method() { | |
console.log(this.name); | |
} | |
}; | |
functions[n] = objects[n].method; | |
} | |
document.getElementById("release").addEventListener("click", function() { | |
objects = null; | |
console.log("objects released"); | |
}); | |
// This is just here so `functions` is used in the code | |
document.getElementById("show-count").addEventListener("click", function() { | |
console.log(functions.length); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment