Am finding memory leaks using chrome(newbie :))
How to identify where the memory is leaking?
And what is Document DOM tree and Detached Dom tree?
Can any one explain me?
Detached DOM elements are the elements which have been removed from the DOM but their memory is still retained because of JavaScript. This means that as long the element have a reference to any variable or an object anywhere, it does not garbage collected even after destroyed from the DOM.
A node is said to be "detached" when it's removed from the DOM tree but some JavaScript still references it. Detached DOM nodes are a common cause of memory leaks. This section teaches you how to use DevTools' heap profilers to identify detached nodes.
The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree.
An example of the DOMTags are element nodes (or just elements) and form the tree structure: <html> is at the root, then <head> and <body> are its children, etc. The text inside elements forms text nodes, labelled as #text . A text node contains only a string. It may not have children and is always a leaf of the tree.
Steps to identify memory leaks.
Steps to identify Detached DOM Trees
You can inspect the detached DOM trees as shown below.
To check what DOM is it you may want to hover over the Red HTML elements as shown below. This helps in debugging once you located the DOM
What are "Document DOM Trees" ? The whole Document is a big DOM Tree inside . Document is XML and the tags are nested thus forming a tree. (DOM - Document Object Model.)
So what are "Detached DOM Trees" ?
HTML elements are instance of objects that consume memory. Each such element can store on them event listeners and data associated with it. Now "Detached DOM Trees" are nothing but DOMs that are in the Browser's memory but are NOT attached to the main DOM tree aka "Document DOM Trees".
By examining these hanging objects we can detect issues and avoid memory leaks.
Solving this problem is a vast topic as you may see some varied solutions out there. Follow following posts for what some people have done to remove the problem.
Can't seem to cleanup detached DOM elements
Javascript Memory Leaks: Detached DOM tree
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With