Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Memory Snapshot Root Path</title>
- <style type="text/css">body { font-family: sans-serif; }</style>
- <script type="text/javascript">
- "use strict";
- window.onload = () => {
- let key;
- const map = new WeakMap();
- const createButton = document.getElementById("createButton");
- const destroyButton = document.getElementById("destroyButton");
- createButton.addEventListener("click", () => {
- key = new SomeKey();
- map.set(key, new Metadata());
- });
- destroyButton.addEventListener("click", () => {
- key = undefined;
- });
- };
- class SomeKey {
- }
- class Metadata {
- constructor() {
- this.large = new LargeObject();
- }
- }
- class LargeObject {
- constructor () {
- this.buffer = new Uint8Array(10 * 1024 * 1024);
- }
- }
- </script>
- </head>
- <body>
- <h1>Chrome Devtools Snapshot WeakMap Retain Path (Issue #773722)</h1>
- <p>
- Click Create button to create a LargeObject instance that is retained via a WeakMap key.
- </p>
- <p>
- Then open the Memory tab of the Dev Tools and take a Heap Snapshot.
- </p>
- <p>
- You will not be able to see the retaining path for this LargeObject and the distance will be "-" even though it is retained via user code and cannot be garbage collected.
- </p>
- <button id="createButton">Create</button>
- <button id="destroyButton">Destroy</button>
- </body>
- </html>
Add Comment
Please, Sign In to add comment