Discussion: How to map traced leaks to React components, or HTML DOM path
See original GitHub issueHi memlab team, Is there any tricks / instruction for mapping console output to react code / html components? I did some homework by reading https://facebook.github.io/memlab/docs/guides/guides-detached-dom However the case I met is not as straightforward as shown in the tutorial.
Detailed: Questions:
- In addition to [window], I also see [(GC roots)], [ < synthetic > ] . How to interpret these kinds?
- How should I translated the below output to a HTML path? In the tutorial, it seems there is –leaked_objects, I don’t see this tag in the below output.
--Similar leaks in this run: 1--
--Retained size of leaked objects: 192 bytes--
[Window] (native) @263277 [6.8KB]
--4 (element)---> [HTMLDocument] (native) @263275 [21.5KB]
--12 (element)---> [Range] (native) @2340276992 [96 bytes]
--3 (element)---> [HTMLDivElement] (native) @262245 [140 bytes]
--4 (element)---> [HTMLDivElement] (native) @262385 [228 bytes]
--3 (element)---> [HTMLDivElement] (native) @262251 [704 bytes]
--__reactInternalInstance$vcd965b8sak (property)---> [FiberNode div HostComponent] (object) @1608501 [304 bytes]
--child (property)---> [FiberNode ClassComponent] (object) @1608615 [220 bytes]
--_debugOwner (property)---> [FiberNode FunctionComponent] (object) @1373349 [3.2KB]
--return (property)---> [FiberNode Modal FunctionComponent] (object) @1373295 [1KB]
--pendingProps (property)---> [Object] (object) @1239415 [60 bytes]
--children (property)---> [Object] (object) @1239305 [388 bytes]
--_owner (property)---> [FiberNode FunctionComponent] (object) @1252139 [192 bytes]
--_debugOwner (property)---> [FiberNode FunctionComponent] (object) @1235961 [192 bytes]
--firstEffect (property)---> [Detached FiberNode render ForwardRef] (object) @2894599 [192 bytes]
Thanks a lot.
Here is the whole console output:
page-load [75.7MB] (baseline) [s1] > action-on-page [69.4MB] (target) [s2] > revert [67.5MB] (final) [s3]
------6 clusters------
--Similar leaks in this run: 1182--
--Retained size of leaked objects: 781.1KB--
[(GC roots)] (synthetic) @3 [819.1KB]
--13 (element)---> [(Global handles)] (synthetic) @29 [10.9KB]
--37 / DevTools console (internal)---> [Detached HTMLSpanElement] (native) @2875845 [781.1KB]
--6 (element)---> [Detached HTMLDivElement] (native) @2875843 [160 bytes]
--8 (element)---> [Detached HTMLDivElement] (native) @2875841 [160 bytes]
--9 (element)---> [Detached HTMLDivElement] (native) @2875709 [160 bytes]
--6 (element)---> [Detached HTMLFormElement] (native) @2875701 [792 bytes]
--7 (element)---> [Detached InternalNode] (native) @2347418720 [0 byte]
--8 (element)---> [Detached HTMLInputElement] (native) @2875595 [1.1KB]
--16 (element)---> [Detached InternalNode] (native) @2340601344 [328 bytes]
--1 (element)---> [Detached ShadowRoot] (native) @2340276032 [328 bytes]
--Similar leaks in this run: 2--
--Retained size of leaked objects: 352 bytes--
[<synthetic>] (synthetic) @1 [72.2MB]
--2 (shortcut)---> [Window / http://localhost:3000/] (object) @9821 [28.5KB]
--FullCalendarVDom (property)---> [Object] (object) @1017785 [544 bytes]
--unmountComponentAtNode (property)---> [unmountComponentAtNode] (closure) @887173 [68 bytes]
--context (internal)---> [<function scope>] (object) @886495 [181KB]
--currentFiber (variable)---> [FiberNode HostRoot] (object) @2936353 [960 bytes]
--firstEffect (property)---> [Detached FiberNode render MemoComponent] (object) @2936359 [192 bytes]
--Similar leaks in this run: 2--
--Retained size of leaked objects: 192 bytes--
[<synthetic>] (synthetic) @1 [72.2MB]
--2 (shortcut)---> [Window / http://localhost:3000/] (object) @9821 [28.5KB]
--asap (property)---> [asap] (closure) @981181 [760 bytes]
--context (internal)---> [<function scope>] (object) @981185 [624 bytes]
--microtask (variable)---> [<closure>] (closure) @2461961 [536 bytes]
--context (internal)---> [<function scope>] (object) @838179 [504 bytes]
--node (variable)---> [Detached Text] (native) @263405 [396 bytes]
--3 (element)---> [Detached InternalNode] (native) @2347375360 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @2340565184 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @2340565344 [272 bytes]
--1 (element)---> [Detached MutationObserverRegistration] (native) @2340565504 [272 bytes]
--1 (element)---> [Detached MutationObserver] (native) @1005061568 [192 bytes]
--1 (element)---> [Detached MutationObserver::Delegate] (native) @1005061408 [80 bytes]
--Similar leaks in this run: 2--
--Retained size of leaked objects: 192 bytes--
[<synthetic>] (synthetic) @1 [72.2MB]
--2 (shortcut)---> [Window / http://localhost:3000/] (object) @9821 [28.5KB]
--Observable (property)---> [Observable] (closure) @981213 [3.3KB]
--context (internal)---> [<function scope>] (object) @981227 [2KB]
--microtask (variable)---> [<closure>] (closure) @2461925 [536 bytes]
--context (internal)---> [<function scope>] (object) @838181 [504 bytes]
--node (variable)---> [Detached Text] (native) @263411 [396 bytes]
--3 (element)---> [Detached InternalNode] (native) @2347375680 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @2340839104 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @2340560864 [272 bytes]
--1 (element)---> [Detached MutationObserverRegistration] (native) @2340560704 [272 bytes]
--1 (element)---> [Detached MutationObserver] (native) @1005062048 [192 bytes]
--1 (element)---> [Detached MutationObserver::Delegate] (native) @1005061888 [80 bytes]
--Similar leaks in this run: 1--
--Retained size of leaked objects: 192 bytes--
[Window] (native) @263277 [6.8KB]
--4 (element)---> [HTMLDocument] (native) @263275 [21.5KB]
--12 (element)---> [Range] (native) @2340276992 [96 bytes]
--3 (element)---> [HTMLDivElement] (native) @262245 [140 bytes]
--4 (element)---> [HTMLDivElement] (native) @262385 [228 bytes]
--3 (element)---> [HTMLDivElement] (native) @262251 [704 bytes]
--__reactInternalInstance$vcd965b8sak (property)---> [FiberNode div HostComponent] (object) @1608501 [304 bytes]
--child (property)---> [FiberNode ClassComponent] (object) @1608615 [220 bytes]
--_debugOwner (property)---> [FiberNode FunctionComponent] (object) @1373349 [3.2KB]
--return (property)---> [FiberNode Modal FunctionComponent] (object) @1373295 [1KB]
--pendingProps (property)---> [Object] (object) @1239415 [60 bytes]
--children (property)---> [Object] (object) @1239305 [388 bytes]
--_owner (property)---> [FiberNode FunctionComponent] (object) @1252139 [192 bytes]
--_debugOwner (property)---> [FiberNode FunctionComponent] (object) @1235961 [192 bytes]
--firstEffect (property)---> [Detached FiberNode render ForwardRef] (object) @2894599 [192 bytes]
--Similar leaks in this run: 1--
--Retained size of leaked objects: 48 bytes--
[Window] (native) @263277 [6.8KB]
--4 (element)---> [HTMLDocument] (native) @263275 [21.5KB]
--jQuery360089431674213560691 (property)---> [Object] (object) @1021743 [2.5KB]
--handle (property)---> [<closure>] (closure) @263137 [52 bytes]
--context (internal)---> [<function scope>] (object) @1577477 [20 bytes]
--previous (internal)---> [<function scope>] (object) @320449 [18.5KB]
--support (variable)---> [Object] (object) @837833 [1.2KB]
--reliableTrDimensions (property)---> [reliableTrDimensions] (closure) @1368867 [68 bytes]
--context (internal)---> [<function scope>] (object) @2206413 [640 bytes]
--div (variable)---> [Detached HTMLDivElement] (native) @263591 [188 bytes]
--3 (element)---> [Detached InternalNode] (native) @995444160 [48 bytes]
--1 (element)---> [Detached CSSStyleDeclaration] (native) @995444000 [48 bytes]
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Thinking in React
Step 1: Break The UI Into A Component Hierarchy · Step 2: Build A Static Version in React · Step 3: Identify The...
Read more >How to work with React the right way to avoid some common ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >sudheerj/reactjs-interview-questions: List of top 500 ... - GitHub
How do you conditionally render components? 68, Why we need to be careful when spreading props on DOM elements?? 69, How you use...
Read more >How To Debug React Components Using React Developer ...
Now that you are on a website that uses React, open the console to access the React Developer Tools. Open the console by...
Read more >Advanced React Router concepts: Recursive path, code ...
import React, { Component } from 'react' import { BrowserRouter as Router, Route, Switch, Link } from 'react-router-dom' import Loadable ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree having a better user interface and APIs for integration with other test frameworks would make MemLab easier to use.
The scope and implementation of Web UI can vary depending on what functionalities to include. Here are some ideas: For basic use cases, adding or extending either one of the following user interfaces could assist memory leak debugging:
memlab view-heap
command, which is a CLI user interface for interacting with a retainer trace (mostly useful on a shell connecting to a remote dev server)For more extended use cases, the Web UI could be a memory leak monitoring and management system. This may involve integration with CI/CD, code searching/viewing system, and backend data stores depending on different orgs’ infra.
For integration with different testing frameworks, this could be implemented by providing APIs that take heap snapshots based on each testing framework (e.g., Playwright, Cypress, Jest). Calling those test-framework-specific APIs in existing tests dumps heap snapshots and meta data in the format that can be processed by the memlab heap analyzer.
Please also check out the discussion in #35.
Hi! @JacksonGL. Thanks for the detailed advice! This sounds great! I’m sure memlab will become an even more influential tool!