Comments (2)
Hi @MaheshDevaraj, please check out the documentation website, specifically the tutorial page which could be useful in understanding the terminal output. Here's the link: https://facebook.github.io/memlab/docs/guides/guides-detached-dom
The memory leak trace produced by MemLab is a reference chain that starts from the GC (garbage collector) root and ends at the leaked object. This reference chain is similar to the retainer path in Chrome DevTool, and there are various online resources available to help you debug a retainer path.
Although the V8 heap snapshot captures limited source information, there are some effective ways to narrow down the scope and identify the relevant code. One way is to use memlab view-heap --node-id <LEAKED_OBJECT_ID>
to obtain more information about the leak trace. To locate the code responsible for creating an object on the trace, search for the intersection of object property names. Alternatively, to locate the code associated with a closure, search for the intersection of variable names in the closure scope.
It's recommended to run the web application being tested with non-minified JS code.
from memlab.
Hi @JacksonGL , Thanks for the updates.
I tried following the above suggestions, In my case in the memlab logs I don't see any variable (leakedObjects from the https://facebook.github.io/memlab/docs/guides/guides-detached-dom , for example). I only see random numbers being shown and from this I'm not able to narrow down to the code that causes the leaks. I also used memlab view-heap --node-id <LEAKED_OBJECT_ID>
and was not able to get any useful informations.
While using Chrome Dev tools memory profile, I'm able to see a link to the code that causes the leak. Can you guide me here? Not sure if I've missed something while using memlab.
Memlab logs from my application:-
MemLab found 7 leak(s)
--Similar leaks in this run: 13--
--Retained size of leaked objects: 105.4KB--
[] (synthetic) @1 [5.3MB]
--2 (shortcut)---> [Window / http://localhost:8000] (object) @9823 [48.6KB]
--require (property)---> [requirejs] (closure) @69911 [3.1KB]
--s (property)---> [Object] (object) @69913 [212 bytes]
--contexts (property)---> [Object] (object) @54171 [96 bytes]
--_ (property)---> [Object] (object) @54173 [2.3KB]
--defined (property)---> [Object] (object) @53929 [37.8KB]
--preact/compat (property)---> [Object] (object) @54089 [9.3KB]
--useTransition (property)---> [K] (closure) @137041 [68 bytes]
--context (internal)---> [] (object) @122325 [116.3KB]
--U (variable)---> [p] (object) @227695 [107.6KB]
--__P (property)---> [Detached HTMLElement] (native) @212991 [105.4KB]
--11 (element)---> [Detached InternalNode] (native) @262836032 [228 bytes]
--2 (element)---> [Detached DOMTokenList] (native) @213075 [84 bytes]
--Similar leaks in this run: 32--
--Retained size of leaked objects: 5.4KB--
[Window] (native) @41625 [52.8KB]
--4 (element)---> [HTMLDocument] (native) @41611 [10.7KB]
--jQuery361067752674121521841 (property)---> [Object] (object) @79307 [836 bytes]
--events (property)---> [Object] (object) @130275 [584 bytes]
--touchcancel (property)---> [Array] (object) @130523 [180 bytes]
--0 (element)---> [Object] (object) @130539 [68 bytes]
--handler (property)---> [native_bind] (closure) @130503 [136 bytes]
--bound_this (internal)---> [constructor] (object) @129375 [8.9KB]
--m_preActiveItem (property)---> [jQuery.fn.init] (object) @242125 [192 bytes]
--0 (element)---> [Detached HTMLLIElement] (native) @212863 [1.3KB]
--8 (element)---> [Detached HTMLAnchorElement] (native) @213121 [1.2KB]
--5 (element)---> [Detached DOMTokenList] (native) @274847456 [56 bytes]
--Similar leaks in this run: 3--
--Retained size of leaked objects: 292 bytes--
[(GC roots)] (synthetic) @3 [598.2KB]
--13 (element)---> [(Global handles)] (synthetic) @29 [1KB]
--10 / DevTools console (internal)---> [Detached HTMLSpanElement] (native) @40985 [688 bytes]
--3 (element)---> [Detached InternalNode] (native) @75016864 [548 bytes]
--6 (element)---> [Detached InternalNode] (native) @75057344 [232 bytes]
--1 (element)---> [Detached NodeList] (native) @213115 [84 bytes]
--Similar leaks in this run: 1--
--Retained size of leaked objects: 272 bytes--
[] (synthetic) @1 [5.3MB]
--2 (shortcut)---> [Window / http://localhost:8000] (object) @9823 [48.6KB]
--oj (property)---> [Object] (object) @53949 [5.8KB]
--CompositeTemplateRenderer (property)---> [Object] (object) @99535 [836 bytes]
--_BINDING_CONTEXT (property)---> [ko.bindingContext] (object) @131325 [68 bytes]
--ko (property)---> [Object] (object) @41837 [38.8KB]
--tasks (property)---> [Object] (object) @123809 [1.4KB]
--scheduler (property)---> [] (closure) @192441 [548 bytes]
--context (internal)---> [] (object) @192757 [480 bytes]
--div (variable)---> [Detached HTMLDivElement] (native) @41691 [412 bytes]
--3 (element)---> [Detached InternalNode] (native) @274838656 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @274900896 [272 bytes]
--1 (element)---> [Detached InternalNode] (native) @274849216 [272 bytes]
--1 (element)---> [Detached MutationObserverRegistration] (native) @262804992 [272 bytes]
--Similar leaks in this run: 3--
--Retained size of leaked objects: 248 bytes--
[Window] (native) @41625 [52.8KB]
--4 (element)---> [HTMLDocument] (native) @41611 [10.7KB]
--10 (element)---> [Range] (native) @56703552 [96 bytes]
--2 (element)---> [HTMLUListElement] (native) @41341 [6.3KB]
--8 (element)---> [HTMLDivElement] (native) @41373 [472 bytes]
--6 (element)---> [HTMLDivElement] (native) @41345 [1.3KB]
--7 (element)---> [HTMLElement] (native) @41083 [14.4KB]
--13 (element)---> [HTMLDivElement] (native) @41085 [664 bytes]
--9 (element)---> [HTMLDivElement] (native) @41567 [752 bytes]
--8 (element)---> [Text] (native) @41031 [124 bytes]
--4 (element)---> [HTMLElement] (native) @41039 [700 bytes]
--6 (element)---> [Text] (native) @41383 [124 bytes]
--4 (element)---> [HTMLDivElement] (native) @41381 [456 bytes]
--7 (element)---> [Text] (native) @41421 [124 bytes]
--4 (element)---> [HTMLUListElement] (native) @41419 [452 bytes]
--6 (element)---> [Text] (native) @41441 [124 bytes]
--4 (element)---> [Comment] (native) @41121 [124 bytes]
--5 (element)---> [Comment] (native) @41125 [3.8KB]
--_templateNode (property)---> [Detached HTMLTemplateElement] (native) @41115 [1.7KB]
--6 (element)---> [Detached DocumentFragment] (native) @41135 [1.1KB]
--5 (element)---> [Detached Text] (native) @75038304 [96 bytes]
--2 (element)---> [Detached HTMLLIElement] (native) @74974464 [808 bytes]
--2 (element)---> [Detached Text] (native) @74994624 [96 bytes]
--2 (element)---> [Detached HTMLAnchorElement] (native) @75012704 [504 bytes]
--1 (element)---> [Detached DOMTokenList] (native) @274834336 [56 bytes]
--Similar leaks in this run: 1--
--Retained size of leaked objects: 56 bytes--
[Window] (native) @41625 [52.8KB]
--4 (element)---> [HTMLDocument] (native) @41611 [10.7KB]
--12 (element)---> [HTMLHtmlElement] (native) @41515 [7.4KB]
--6 (element)---> [HTMLBodyElement] (native) @41589 [312 bytes]
--5 (element)---> [Text] (native) @75010304 [96 bytes]
--2 (element)---> [Comment] (native) @75009984 [96 bytes]
--3 (element)---> [Text] (native) @262852832 [96 bytes]
--3 (element)---> [HTMLScriptElement] (native) @40819 [3KB]
--__ko__1679020612580 (property)---> [Object] (object) @131615 [2.5KB]
--4__ko__1679020612580 (property)---> [Object] (object) @131629 [2.4KB]
--containerData (property)---> [Detached HTMLDivElement] (native) @40829 [2.2KB]
--4 (element)---> [Detached Text] (native) @40825 [124 bytes]
--4 (element)---> [Detached HTMLLIElement] (native) @40823 [1.8KB]
--3 (element)---> [Detached HTMLAnchorElement] (native) @40835 [372 bytes]
--3 (element)---> [Detached DOMTokenList] (native) @274896416 [56 bytes]
--Similar leaks in this run: 1--
--Retained size of leaked objects: 48 bytes--
[] (synthetic) @1 [5.3MB]
--2 (shortcut)---> [Window / http://localhost:8000] (object) @9823 [48.6KB]
--$ (property)---> [jQuery] (closure) @50567 [26.1KB]
--support (property)---> [Object] (object) @93481 [1.2KB]
--reliableTrDimensions (property)---> [reliableTrDimensions] (closure) @192215 [68 bytes]
--context (internal)---> [] (object) @193043 [640 bytes]
--div (variable)---> [Detached HTMLDivElement] (native) @41553 [188 bytes]
--3 (element)---> [Detached InternalNode] (native) @262884032 [48 bytes]
--1 (element)---> [Detached CSSStyleDeclaration] (native) @274845856 [48 bytes]
from memlab.
Related Issues (20)
- Can't switch chrome version HOT 2
- Idea - Question - Discussion - Using memlab to refactor code targeting different framework philosphy HOT 1
- Question - How does it pull memory information ? HOT 1
- 老哥有点问题,本地默认安装你的仓库里面有个依赖包引入 colors 的包默认是1.4.2的 被污染的那个包 导致 启动不起来,windows 开发环境, HOT 2
- Question: Any idea about ignoring weak reference and circular reference in heap snapshot? HOT 7
- takeHeapSnapshot timed out HOT 10
- core_1.browserInfo.setPuppeteerConfig is not a function HOT 2
- Is there a way to run in scripting mode using silent? HOT 6
- Could not find Chrome (ver. 121.0.6167.85). This can occur if either 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or 2. your cache path is incorrectly configured HOT 5
- Could not find Chrome (ver. 121.0.6167.85). This can occur if either 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or 2. your cache path is incorrectly configured
- Keep `@memlab/*` versions in lockstep in package.json HOT 1
- how to handle Page crashed error ,when execute the run method。 HOT 1
- how to get leak info from memlab console HOT 6
- Clarify the documentation about measure mode HOT 3
- Using a basic `retainerReferenceFilter` causes Node OOM exception HOT 7
- How can I use script_id in IHeapLocation to get js url ? HOT 2
- Runtime exit code 1 during testInBrowser when running in AWS Lambda
- TypeError: core_1.utils.tryToMutePuppeteerWarning is not a function HOT 2
- Error occurs when executing scenarios involving dialog display HOT 1
- Need guidance on accessing elements in code using heap object ID HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memlab.