Skip to content

Instantly share code, notes, and snippets.

@tjcrowder
Created February 17, 2019 17:32
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 tjcrowder/8a6993d8c8cd204c21667c3856f01ae1 to your computer and use it in GitHub Desktop.
Save tjcrowder/8a6993d8c8cd204c21667c3856f01ae1 to your computer and use it in GitHub Desktop.
<!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