Goal: Observe how creating many objects affects memory allocation
Steps:
Goal: Identify memory leaks caused by event listeners
Steps:
Goal: Understand circular references in memory
Steps:
Goal: Learn about linked list memory management and references
Steps:
Goal: Learn about DOM element memory management
Steps:
Why do all DOM nodes show the same Distance?
In Browser's heap snapshot, Distance is the shortest retaining path from any GC root to the object.
All DOM nodes show the same distance because the browser engine internally maintains direct references to every attached DOM node through internal data structures (e.g., the document's node table/registry). This means every node β whether at depth 0 or depth 20 β has an equally short path from the GC root through these internal structures.
The distance is not calculated by walking the parentβchild DOM hierarchy. Even though tree-node-20 is 20 levels deep in the DOM tree, Browser's internals provide a shortcut that makes it just as reachable as tree-node-0.
Compare this with Exercise 4 (Linked List): plain JavaScript objects don't get this internal shortcut, so their Distance values increase along the chain.
To see this in action, the "Grow Family Tree" button also creates a mirrored JS object chain (π_jsTreeNode_π) with the same depth. Search for jsTreeNode in the heap snapshot β you'll see Distance values increasing from depth 0 to depth 20, unlike the DOM nodes which all share the same Distance.