From 22596d32b504f61c4b6a7fdabc81ffbd23fe6357 Mon Sep 17 00:00:00 2001 From: facebook-github-bot Date: Fri, 30 Aug 2024 23:50:44 +0000 Subject: [PATCH] deploy: 4f6de3d1efe39762217f53d43b351437aabb8411 --- 404.html | 4 +- ...e0bf7.13851d34.js => 015e0bf7.0e281620.js} | 2 +- ...eefc4.837908c5.js => 086eefc4.ffc16a5b.js} | 2 +- ...3082f.cd21904c.js => 0d63082f.c50dc84f.js} | 2 +- ...6ea57.e5e89145.js => 0ee6ea57.ed0b5255.js} | 2 +- ...76b7a.6e511fc9.js => 1bb76b7a.ffb915e4.js} | 2 +- ...ba521.ce8dcbb8.js => 26eba521.ab50ddbe.js} | 2 +- ...52c34.5e2cc3fe.js => 27652c34.d0a6a2c5.js} | 2 +- ...affd8.faed0bb1.js => 2d8affd8.b192b553.js} | 2 +- ...ac66d.f5f0f42b.js => 2ecac66d.327215f5.js} | 2 +- ...1de3b.3c9fc781.js => 3531de3b.8689b73f.js} | 2 +- ...7bbe9.81ee2013.js => 4527bbe9.46c3ba3a.js} | 2 +- ...7db6f.1d864fde.js => 5a17db6f.ed14df67.js} | 2 +- ...d4bc5.6137fd8c.js => 5b1d4bc5.c90c1034.js} | 2 +- ...78946.b2dc5a65.js => 5be78946.84581dc3.js} | 2 +- ...d7254.1a2b0df8.js => 6b5d7254.4c379e61.js} | 2 +- ...ddb53.8615eb0d.js => 72eddb53.1a366387.js} | 2 +- ...1a35a.7de6fb63.js => 8b21a35a.4757b023.js} | 2 +- ...06942.2869ba06.js => 95206942.0c281ce3.js} | 2 +- ...47cf5.7e757fda.js => 95f47cf5.53ed909a.js} | 2 +- ...9c166.cac6eee1.js => 98c9c166.ebb42bed.js} | 2 +- ...f1d78.2c145d5a.js => b53f1d78.11c43043.js} | 2 +- ...dd339.bc9326e4.js => c90dd339.f50c64ca.js} | 2 +- ...2388a.1d2da296.js => e012388a.6146abb3.js} | 2 +- ...6f3cc.14f34b89.js => e4c6f3cc.d050fdd8.js} | 2 +- ...f92ec.840cd345.js => f40f92ec.613fb13e.js} | 2 +- ...99c11.c0c9117e.js => f8599c11.7647fd3b.js} | 2 +- ...c0a35.85c8b236.js => fc5c0a35.8eda2a00.js} | 2 +- assets/js/runtime~main.9f42d73f.js | 1 + assets/js/runtime~main.c29219a0.js | 1 - .../index.html | 12 ++-- .../api_src.SnapshotResultReader/index.html | 10 +-- .../heap_analysis_src.BaseAnalysis/index.html | 14 ++-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- .../index.html | 8 +-- docs/api/enums/api_src.ConsoleMode/index.html | 6 +- docs/api/index.html | 4 +- .../core_src.IBrowserInfo/index.html | 6 +- .../interfaces/core_src.IHeapEdge/index.html | 20 +++--- .../interfaces/core_src.IHeapEdges/index.html | 10 +-- .../core_src.IHeapLocation/index.html | 10 +-- .../interfaces/core_src.IHeapNode/index.html | 64 +++++++++--------- .../interfaces/core_src.IHeapNodes/index.html | 10 +-- .../core_src.IHeapSnapshot/index.html | 22 +++---- .../core_src.IHeapStringNode/index.html | 66 +++++++++---------- .../core_src.ILeakFilter/index.html | 10 +-- .../interfaces/core_src.IScenario/index.html | 26 ++++---- docs/api/modules/api_src/index.html | 18 ++--- docs/api/modules/core_src/index.html | 32 ++++----- docs/api/modules/heap_analysis_src/index.html | 24 +++---- docs/cli/CLI-commands/index.html | 4 +- docs/getting-started/index.html | 4 +- docs/guides/guides-detached-dom/index.html | 4 +- .../guides-detect-oversized-object/index.html | 4 +- docs/guides/guides-find-leaks/index.html | 4 +- .../integrate-with-e2e-frameworks/index.html | 4 +- .../integration-and-file-structure/index.html | 4 +- docs/how-memlab-works/index.html | 4 +- docs/installation/index.html | 4 +- docs/intro/index.html | 4 +- index.html | 4 +- search/index.html | 4 +- under-construction/index.html | 4 +- 71 files changed, 278 insertions(+), 278 deletions(-) rename assets/js/{015e0bf7.13851d34.js => 015e0bf7.0e281620.js} (98%) rename assets/js/{086eefc4.837908c5.js => 086eefc4.ffc16a5b.js} (97%) rename assets/js/{0d63082f.cd21904c.js => 0d63082f.c50dc84f.js} (97%) rename assets/js/{0ee6ea57.e5e89145.js => 0ee6ea57.ed0b5255.js} (96%) rename assets/js/{1bb76b7a.6e511fc9.js => 1bb76b7a.ffb915e4.js} (93%) rename assets/js/{26eba521.ce8dcbb8.js => 26eba521.ab50ddbe.js} (97%) rename assets/js/{27652c34.5e2cc3fe.js => 27652c34.d0a6a2c5.js} (95%) rename assets/js/{2d8affd8.faed0bb1.js => 2d8affd8.b192b553.js} (96%) rename assets/js/{2ecac66d.f5f0f42b.js => 2ecac66d.327215f5.js} (94%) rename assets/js/{3531de3b.3c9fc781.js => 3531de3b.8689b73f.js} (88%) rename assets/js/{4527bbe9.81ee2013.js => 4527bbe9.46c3ba3a.js} (98%) rename assets/js/{5a17db6f.1d864fde.js => 5a17db6f.ed14df67.js} (98%) rename assets/js/{5b1d4bc5.6137fd8c.js => 5b1d4bc5.c90c1034.js} (97%) rename assets/js/{5be78946.b2dc5a65.js => 5be78946.84581dc3.js} (98%) rename assets/js/{6b5d7254.1a2b0df8.js => 6b5d7254.4c379e61.js} (91%) rename assets/js/{72eddb53.8615eb0d.js => 72eddb53.1a366387.js} (98%) rename assets/js/{8b21a35a.7de6fb63.js => 8b21a35a.4757b023.js} (98%) rename assets/js/{95206942.2869ba06.js => 95206942.0c281ce3.js} (98%) rename assets/js/{95f47cf5.7e757fda.js => 95f47cf5.53ed909a.js} (98%) rename assets/js/{98c9c166.cac6eee1.js => 98c9c166.ebb42bed.js} (92%) rename assets/js/{b53f1d78.2c145d5a.js => b53f1d78.11c43043.js} (95%) rename assets/js/{c90dd339.bc9326e4.js => c90dd339.f50c64ca.js} (97%) rename assets/js/{e012388a.1d2da296.js => e012388a.6146abb3.js} (92%) rename assets/js/{e4c6f3cc.14f34b89.js => e4c6f3cc.d050fdd8.js} (97%) rename assets/js/{f40f92ec.840cd345.js => f40f92ec.613fb13e.js} (95%) rename assets/js/{f8599c11.c0c9117e.js => f8599c11.7647fd3b.js} (97%) rename assets/js/{fc5c0a35.85c8b236.js => fc5c0a35.8eda2a00.js} (96%) create mode 100644 assets/js/runtime~main.9f42d73f.js delete mode 100644 assets/js/runtime~main.c29219a0.js diff --git a/404.html b/404.html index d8b5843f..13308cca 100644 --- a/404.html +++ b/404.html @@ -10,14 +10,14 @@ Page Not Found | memlab - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/015e0bf7.13851d34.js b/assets/js/015e0bf7.0e281620.js similarity index 98% rename from assets/js/015e0bf7.13851d34.js rename to assets/js/015e0bf7.0e281620.js index 4d71ed53..0471ab50 100644 --- a/assets/js/015e0bf7.13851d34.js +++ b/assets/js/015e0bf7.0e281620.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2775],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>m});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function r(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):r(r({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},g="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,i=e.originalType,o=e.parentName,y=l(e,["components","mdxType","originalType","parentName"]),g=p(n),u=s,m=g["".concat(o,".").concat(u)]||g[u]||c[u]||i;return n?t.createElement(m,r(r({ref:a},y),{},{components:n})):t.createElement(m,r({ref:a},y))}));function m(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var i=n.length,r=new Array(i);r[0]=u;var l={};for(var o in a)hasOwnProperty.call(a,o)&&(l[o]=a[o]);l.originalType=e,l[g]="string"==typeof e?e:s,r[1]=l;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>r,default:()=>c,frontMatter:()=>i,metadata:()=>l,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const i={id:"heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",sidebar_label:"StringAnalysis",custom_edit_url:null},r=void 0,l={unversionedId:"api/classes/heap_analysis_src.StringAnalysis",id:"api/classes/heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",description:"This analysis finds duplicated string instance in JavaScript heap",source:"@site/docs/api/classes/heap_analysis_src.StringAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",sidebar_label:"StringAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},next:{title:"IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new StringAnalysis()',id:"new-stringanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getTopDuplicatedStringsInCount()',id:"gettopduplicatedstringsincount",level:3}],y={toc:p},g="wrapper";function c(e){let{components:a,...n}=e;return(0,s.yg)(g,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("p",null,"This analysis finds duplicated string instance in JavaScript heap\nand rank them based on the duplicated string size and count."),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"StringAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-stringanalysis"},(0,s.yg)("a",{id:"new stringanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new StringAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"get CLI command name for this memory analysis;\nuse it with ",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")," in CLI"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"p"},"string")," | command name")),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Source"),":"),(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/StringAnalysis.ts#L118"},"heap-analysis/src/plugins/StringAnalysis.ts:118"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"gettopduplicatedstringsincount"},(0,s.yg)("a",{id:"gettopduplicatedstringsincount"}),(0,s.yg)("strong",{parentName:"h3"},"getTopDuplicatedStringsInCount"),"()"),(0,s.yg)("p",null,"get the top duplicated string in terms of duplicated string count"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"p"},"StringRecord"),"[] | an array of the top-duplicated strings' information")),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Source"),":"),(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/StringAnalysis.ts#L68"},"heap-analysis/src/plugins/StringAnalysis.ts:68"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2775],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>m});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function r(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):r(r({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},g="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,i=e.originalType,o=e.parentName,y=l(e,["components","mdxType","originalType","parentName"]),g=p(n),u=s,m=g["".concat(o,".").concat(u)]||g[u]||c[u]||i;return n?t.createElement(m,r(r({ref:a},y),{},{components:n})):t.createElement(m,r({ref:a},y))}));function m(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var i=n.length,r=new Array(i);r[0]=u;var l={};for(var o in a)hasOwnProperty.call(a,o)&&(l[o]=a[o]);l.originalType=e,l[g]="string"==typeof e?e:s,r[1]=l;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>r,default:()=>c,frontMatter:()=>i,metadata:()=>l,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const i={id:"heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",sidebar_label:"StringAnalysis",custom_edit_url:null},r=void 0,l={unversionedId:"api/classes/heap_analysis_src.StringAnalysis",id:"api/classes/heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",description:"This analysis finds duplicated string instance in JavaScript heap",source:"@site/docs/api/classes/heap_analysis_src.StringAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.StringAnalysis",title:"Class: StringAnalysis",sidebar_label:"StringAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},next:{title:"IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new StringAnalysis()',id:"new-stringanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getTopDuplicatedStringsInCount()',id:"gettopduplicatedstringsincount",level:3}],y={toc:p},g="wrapper";function c(e){let{components:a,...n}=e;return(0,s.yg)(g,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("p",null,"This analysis finds duplicated string instance in JavaScript heap\nand rank them based on the duplicated string size and count."),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"StringAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-stringanalysis"},(0,s.yg)("a",{id:"new stringanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new StringAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"get CLI command name for this memory analysis;\nuse it with ",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")," in CLI"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"p"},"string")," | command name")),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Source"),":"),(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/StringAnalysis.ts#L118"},"heap-analysis/src/plugins/StringAnalysis.ts:118"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"gettopduplicatedstringsincount"},(0,s.yg)("a",{id:"gettopduplicatedstringsincount"}),(0,s.yg)("strong",{parentName:"h3"},"getTopDuplicatedStringsInCount"),"()"),(0,s.yg)("p",null,"get the top duplicated string in terms of duplicated string count"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"p"},"StringRecord"),"[] | an array of the top-duplicated strings' information")),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("strong",{parentName:"p"},"Source"),":"),(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/StringAnalysis.ts#L68"},"heap-analysis/src/plugins/StringAnalysis.ts:68"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/086eefc4.837908c5.js b/assets/js/086eefc4.ffc16a5b.js similarity index 97% rename from assets/js/086eefc4.837908c5.js rename to assets/js/086eefc4.ffc16a5b.js index 81054f22..ab2acde0 100644 --- a/assets/js/086eefc4.837908c5.js +++ b/assets/js/086eefc4.ffc16a5b.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6192],{5680:(e,a,t)=>{t.d(a,{xA:()=>g,yg:()=>d});var n=t(6540);function r(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function s(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);a&&(n=n.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var a=1;a=0||(r[t]=e[t]);return r}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var i=n.createContext({}),p=function(e){var a=n.useContext(i),t=a;return e&&(t="function"==typeof e?e(a):l(l({},a),e)),t},g=function(e){var a=p(e.components);return n.createElement(i.Provider,{value:a},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return n.createElement(n.Fragment,{},a)}},m=n.forwardRef((function(e,a){var t=e.components,r=e.mdxType,s=e.originalType,i=e.parentName,g=o(e,["components","mdxType","originalType","parentName"]),u=p(t),m=r,d=u["".concat(i,".").concat(m)]||u[m]||c[m]||s;return t?n.createElement(d,l(l({ref:a},g),{},{components:t})):n.createElement(d,l({ref:a},g))}));function d(e,a){var t=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var s=t.length,l=new Array(s);l[0]=m;var o={};for(var i in a)hasOwnProperty.call(a,i)&&(o[i]=a[i]);o.originalType=e,o[u]="string"==typeof e?e:r,l[1]=o;for(var p=2;p{t.r(a),t.d(a,{assets:()=>i,contentTitle:()=>l,default:()=>c,frontMatter:()=>s,metadata:()=>o,toc:()=>p});var n=t(8168),r=(t(6540),t(5680));const s={id:"api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",sidebar_label:"SnapshotResultReader",custom_edit_url:null},l=void 0,o={unversionedId:"api/classes/api_src.SnapshotResultReader",id:"api/classes/api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",description:"A utility entity to read all MemLab files generated from",source:"@site/docs/api/classes/api_src.SnapshotResultReader.md",sourceDirName:"api/classes",slug:"/api/classes/api_src.SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",sidebar_label:"SnapshotResultReader",custom_edit_url:null},sidebar:"sidebar",previous:{title:"BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},next:{title:"BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"}},i={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Methods",id:"methods",level:2},{value:'getConsoleBackupFile()',id:"getconsolebackupfile",level:3},{value:'getInteractionSteps()',id:"getinteractionsteps",level:3},{value:'getRootDirectory()',id:"getrootdirectory",level:3},{value:'getSnapshotFiles()',id:"getsnapshotfiles",level:3},{value:'Static fromSnapshots(baselineSnapshot, targetSnapshot, finalSnapshot)',id:"static-fromsnapshotsbaselinesnapshot-targetsnapshot-finalsnapshot",level:3}],g={toc:p},u="wrapper";function c(e){let{components:a,...t}=e;return(0,r.yg)(u,(0,n.A)({},g,t,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"A utility entity to read all MemLab files generated from\nbaseline, target and final heap snapshots."),(0,r.yg)("p",null,"The most useful feature of this class is when you have\nthree separate snapshots (baseline, target, and final)\nthat are not taken from MemLab, but you still would\nlike to use the ",(0,r.yg)("inlineCode",{parentName:"p"},"findLeaks")," to detect memory leaks:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader, findLeaks} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst leaks = await findLeaks(reader);\n")),(0,r.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("inlineCode",{parentName:"p"},"default")),(0,r.yg)("p",{parentName:"li"},"\u21b3 ",(0,r.yg)("strong",{parentName:"p"},(0,r.yg)("inlineCode",{parentName:"strong"},"SnapshotResultReader"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getconsolebackupfile"},(0,r.yg)("a",{id:"getconsolebackupfile"}),(0,r.yg)("strong",{parentName:"h3"},"getConsoleBackupFile"),"()"),(0,r.yg)("p",null,"This method gets the backup file of the console output."),(0,r.yg)("p",null,"The memlab CLI commands (e.g., ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks"),") outputs a\nnon-structured string representation for easy reading, while the\nAPIs (e.g., ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks")),") return structured leaks\nrepresentation that is handy for post-processing. If you need to\nobtain all the string output from the CLI in the current working directory,\nyou can read them from the CLI output backup file returned by this method."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the backup file"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots, findLeaks} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n const leaks = await findLeaks(result);\n\n // get the console output backup file\n const consoleBackupFile = result.getConsoleBackupFile();\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BaseResultReader.ts#L102"},"api/src/result-reader/BaseResultReader.ts:102"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getinteractionsteps"},(0,r.yg)("a",{id:"getinteractionsteps"}),(0,r.yg)("strong",{parentName:"h3"},"getInteractionSteps"),"()"),(0,r.yg)("p",null,"browser interaction step sequence"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"E2EStepInfo"),"[] | an array of browser interaction step information")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst paths = reader.getInteractionSteps();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/SnapshotResultReader.ts#L159"},"api/src/result-reader/SnapshotResultReader.ts:159"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getrootdirectory"},(0,r.yg)("a",{id:"getrootdirectory"}),(0,r.yg)("strong",{parentName:"h3"},"getRootDirectory"),"()"),(0,r.yg)("p",null,"get the directory where the data and generated files of\nthe memlab run were stored"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | absolute path of the directory"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the directory that stores all the files\n // generated from the takeSnapshots call\n const dataDir = result.getRootDirectory();\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BaseResultReader.ts#L72"},"api/src/result-reader/BaseResultReader.ts:72"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getsnapshotfiles"},(0,r.yg)("a",{id:"getsnapshotfiles"}),(0,r.yg)("strong",{parentName:"h3"},"getSnapshotFiles"),"()"),(0,r.yg)("p",null,"get all snapshot files related to this SnapshotResultReader"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"string"),"[] | an array of snapshot file's absolute path")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst paths = reader.getSnapshotFiles();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/SnapshotResultReader.ts#L132"},"api/src/result-reader/SnapshotResultReader.ts:132"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"static-fromsnapshotsbaselinesnapshot-targetsnapshot-finalsnapshot"},(0,r.yg)("a",{id:"fromsnapshots"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Static")," ",(0,r.yg)("strong",{parentName:"h3"},"fromSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"baselineSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"targetSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"finalSnapshot"),")"),(0,r.yg)("p",null,"Build a result reader from baseline, target, and final heap snapshot files.\nThe three snapshot files do not have to be in the same directory."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"baselineSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the baseline heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"targetSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the target heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"finalSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the final heap snapshot"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"SnapshotResultReader"))," | the ResultReader instance")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader, findLeaks} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst leaks = await findLeaks(reader);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/SnapshotResultReader.ts#L99"},"api/src/result-reader/SnapshotResultReader.ts:99"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6192],{5680:(e,a,t)=>{t.d(a,{xA:()=>g,yg:()=>d});var n=t(6540);function r(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}function s(e,a){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);a&&(n=n.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var a=1;a=0||(r[t]=e[t]);return r}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var i=n.createContext({}),p=function(e){var a=n.useContext(i),t=a;return e&&(t="function"==typeof e?e(a):l(l({},a),e)),t},g=function(e){var a=p(e.components);return n.createElement(i.Provider,{value:a},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return n.createElement(n.Fragment,{},a)}},m=n.forwardRef((function(e,a){var t=e.components,r=e.mdxType,s=e.originalType,i=e.parentName,g=o(e,["components","mdxType","originalType","parentName"]),u=p(t),m=r,d=u["".concat(i,".").concat(m)]||u[m]||c[m]||s;return t?n.createElement(d,l(l({ref:a},g),{},{components:t})):n.createElement(d,l({ref:a},g))}));function d(e,a){var t=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var s=t.length,l=new Array(s);l[0]=m;var o={};for(var i in a)hasOwnProperty.call(a,i)&&(o[i]=a[i]);o.originalType=e,o[u]="string"==typeof e?e:r,l[1]=o;for(var p=2;p{t.r(a),t.d(a,{assets:()=>i,contentTitle:()=>l,default:()=>c,frontMatter:()=>s,metadata:()=>o,toc:()=>p});var n=t(8168),r=(t(6540),t(5680));const s={id:"api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",sidebar_label:"SnapshotResultReader",custom_edit_url:null},l=void 0,o={unversionedId:"api/classes/api_src.SnapshotResultReader",id:"api/classes/api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",description:"A utility entity to read all MemLab files generated from",source:"@site/docs/api/classes/api_src.SnapshotResultReader.md",sourceDirName:"api/classes",slug:"/api/classes/api_src.SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.SnapshotResultReader",title:"Class: SnapshotResultReader",sidebar_label:"SnapshotResultReader",custom_edit_url:null},sidebar:"sidebar",previous:{title:"BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},next:{title:"BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"}},i={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Methods",id:"methods",level:2},{value:'getConsoleBackupFile()',id:"getconsolebackupfile",level:3},{value:'getInteractionSteps()',id:"getinteractionsteps",level:3},{value:'getRootDirectory()',id:"getrootdirectory",level:3},{value:'getSnapshotFiles()',id:"getsnapshotfiles",level:3},{value:'Static fromSnapshots(baselineSnapshot, targetSnapshot, finalSnapshot)',id:"static-fromsnapshotsbaselinesnapshot-targetsnapshot-finalsnapshot",level:3}],g={toc:p},u="wrapper";function c(e){let{components:a,...t}=e;return(0,r.yg)(u,(0,n.A)({},g,t,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"A utility entity to read all MemLab files generated from\nbaseline, target and final heap snapshots."),(0,r.yg)("p",null,"The most useful feature of this class is when you have\nthree separate snapshots (baseline, target, and final)\nthat are not taken from MemLab, but you still would\nlike to use the ",(0,r.yg)("inlineCode",{parentName:"p"},"findLeaks")," to detect memory leaks:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader, findLeaks} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst leaks = await findLeaks(reader);\n")),(0,r.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("inlineCode",{parentName:"p"},"default")),(0,r.yg)("p",{parentName:"li"},"\u21b3 ",(0,r.yg)("strong",{parentName:"p"},(0,r.yg)("inlineCode",{parentName:"strong"},"SnapshotResultReader"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getconsolebackupfile"},(0,r.yg)("a",{id:"getconsolebackupfile"}),(0,r.yg)("strong",{parentName:"h3"},"getConsoleBackupFile"),"()"),(0,r.yg)("p",null,"This method gets the backup file of the console output."),(0,r.yg)("p",null,"The memlab CLI commands (e.g., ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks"),") outputs a\nnon-structured string representation for easy reading, while the\nAPIs (e.g., ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks")),") return structured leaks\nrepresentation that is handy for post-processing. If you need to\nobtain all the string output from the CLI in the current working directory,\nyou can read them from the CLI output backup file returned by this method."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the backup file"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots, findLeaks} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n const leaks = await findLeaks(result);\n\n // get the console output backup file\n const consoleBackupFile = result.getConsoleBackupFile();\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BaseResultReader.ts#L102"},"api/src/result-reader/BaseResultReader.ts:102"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getinteractionsteps"},(0,r.yg)("a",{id:"getinteractionsteps"}),(0,r.yg)("strong",{parentName:"h3"},"getInteractionSteps"),"()"),(0,r.yg)("p",null,"browser interaction step sequence"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"E2EStepInfo"),"[] | an array of browser interaction step information")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst paths = reader.getInteractionSteps();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/SnapshotResultReader.ts#L159"},"api/src/result-reader/SnapshotResultReader.ts:159"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getrootdirectory"},(0,r.yg)("a",{id:"getrootdirectory"}),(0,r.yg)("strong",{parentName:"h3"},"getRootDirectory"),"()"),(0,r.yg)("p",null,"get the directory where the data and generated files of\nthe memlab run were stored"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | absolute path of the directory"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the directory that stores all the files\n // generated from the takeSnapshots call\n const dataDir = result.getRootDirectory();\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BaseResultReader.ts#L72"},"api/src/result-reader/BaseResultReader.ts:72"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getsnapshotfiles"},(0,r.yg)("a",{id:"getsnapshotfiles"}),(0,r.yg)("strong",{parentName:"h3"},"getSnapshotFiles"),"()"),(0,r.yg)("p",null,"get all snapshot files related to this SnapshotResultReader"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"string"),"[] | an array of snapshot file's absolute path")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst paths = reader.getSnapshotFiles();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/SnapshotResultReader.ts#L132"},"api/src/result-reader/SnapshotResultReader.ts:132"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"static-fromsnapshotsbaselinesnapshot-targetsnapshot-finalsnapshot"},(0,r.yg)("a",{id:"fromsnapshots"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Static")," ",(0,r.yg)("strong",{parentName:"h3"},"fromSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"baselineSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"targetSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"finalSnapshot"),")"),(0,r.yg)("p",null,"Build a result reader from baseline, target, and final heap snapshot files.\nThe three snapshot files do not have to be in the same directory."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"baselineSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the baseline heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"targetSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the target heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"finalSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | file path of the final heap snapshot"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"SnapshotResultReader"))," | the ResultReader instance")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {SnapshotResultReader, findLeaks} = require('@memlab/api');\n\n// baseline, target, and final are file paths of heap snapshot files\nconst reader = SnapshotResultReader.fromSnapshots(baseline, target, final);\nconst leaks = await findLeaks(reader);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/SnapshotResultReader.ts#L99"},"api/src/result-reader/SnapshotResultReader.ts:99"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/0d63082f.cd21904c.js b/assets/js/0d63082f.c50dc84f.js similarity index 97% rename from assets/js/0d63082f.cd21904c.js rename to assets/js/0d63082f.c50dc84f.js index 454a4b15..4f41345c 100644 --- a/assets/js/0d63082f.cd21904c.js +++ b/assets/js/0d63082f.c50dc84f.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[5214],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>u});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),p=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return s.createElement(o.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},c=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),g=p(n),c=t,u=g["".concat(o,".").concat(c)]||g[c]||m[c]||l;return n?s.createElement(u,i(i({ref:a},y),{},{components:n})):s.createElement(u,i({ref:a},y))}));function u(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=c;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[g]="string"==typeof e?e:t,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",sidebar_label:"BaseAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.BaseAnalysis",id:"api/classes/heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.BaseAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",sidebar_label:"BaseAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},next:{title:"CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new BaseAnalysis()',id:"new-baseanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getDescription()',id:"getdescription",level:3},{value:'getOptions()',id:"getoptions",level:3},{value:'process(options)',id:"processoptions",level:3}],y={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(g,(0,s.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"Analysis")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"BaseAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"DetachedDOMElementAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"GlobalVariableAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"CollectionsHoldingStaleAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectShallowAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectSizeAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ShapeUnboundGrowthAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectFanoutAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectShapeAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectUnboundGrowthAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"StringAnalysis"))))),(0,t.yg)("h2",{id:"constructors"},"Constructors"),(0,t.yg)("h3",{id:"new-baseanalysis"},(0,t.yg)("a",{id:"new baseanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"new BaseAnalysis"),"()"),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,t.yg)("a",{id:"analyzesnapshotfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,t.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,t.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getcommandname"},(0,t.yg)("a",{id:"getcommandname"}),(0,t.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,t.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,t.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L189"},"heap-analysis/src/BaseAnalysis.ts:189"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getdescription"},(0,t.yg)("a",{id:"getdescription"}),(0,t.yg)("strong",{parentName:"h3"},"getDescription"),"()"),(0,t.yg)("p",null,"Get the textual description of the heap analysis.\nThe description of this analysis will be printed by:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze list")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"string")," | the description")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L201"},"heap-analysis/src/BaseAnalysis.ts:201"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getoptions"},(0,t.yg)("a",{id:"getoptions"}),(0,t.yg)("strong",{parentName:"h3"},"getOptions"),"()"),(0,t.yg)("p",null,"override this method if you would like CLI to print the option info"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"default"),"[] | an array of command line options")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L228"},"heap-analysis/src/BaseAnalysis.ts:228"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"processoptions"},(0,t.yg)("a",{id:"process"}),(0,t.yg)("strong",{parentName:"h3"},"process"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Callback for ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze "),".\nDo the memory analysis and print results in this callback\nThe analysis should support:\n1) printing results on screen\n2) returning results via the return value"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | This is the auto-generated arguments passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"process")," method that your self-defined heap analysis should implement. You are not supposed to construct instances of this class."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"any"),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L216"},"heap-analysis/src/BaseAnalysis.ts:216"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[5214],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>u});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),p=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return s.createElement(o.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},c=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),g=p(n),c=t,u=g["".concat(o,".").concat(c)]||g[c]||m[c]||l;return n?s.createElement(u,i(i({ref:a},y),{},{components:n})):s.createElement(u,i({ref:a},y))}));function u(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=c;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[g]="string"==typeof e?e:t,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",sidebar_label:"BaseAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.BaseAnalysis",id:"api/classes/heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.BaseAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.BaseAnalysis",title:"Class: BaseAnalysis",sidebar_label:"BaseAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},next:{title:"CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new BaseAnalysis()',id:"new-baseanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getDescription()',id:"getdescription",level:3},{value:'getOptions()',id:"getoptions",level:3},{value:'process(options)',id:"processoptions",level:3}],y={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(g,(0,s.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"Analysis")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"BaseAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"DetachedDOMElementAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"GlobalVariableAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"CollectionsHoldingStaleAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectShallowAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectSizeAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ShapeUnboundGrowthAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectFanoutAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectShapeAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"ObjectUnboundGrowthAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"StringAnalysis"))))),(0,t.yg)("h2",{id:"constructors"},"Constructors"),(0,t.yg)("h3",{id:"new-baseanalysis"},(0,t.yg)("a",{id:"new baseanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"new BaseAnalysis"),"()"),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,t.yg)("a",{id:"analyzesnapshotfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,t.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,t.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getcommandname"},(0,t.yg)("a",{id:"getcommandname"}),(0,t.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,t.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,t.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L189"},"heap-analysis/src/BaseAnalysis.ts:189"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getdescription"},(0,t.yg)("a",{id:"getdescription"}),(0,t.yg)("strong",{parentName:"h3"},"getDescription"),"()"),(0,t.yg)("p",null,"Get the textual description of the heap analysis.\nThe description of this analysis will be printed by:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze list")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"string")," | the description")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L201"},"heap-analysis/src/BaseAnalysis.ts:201"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getoptions"},(0,t.yg)("a",{id:"getoptions"}),(0,t.yg)("strong",{parentName:"h3"},"getOptions"),"()"),(0,t.yg)("p",null,"override this method if you would like CLI to print the option info"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"default"),"[] | an array of command line options")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L228"},"heap-analysis/src/BaseAnalysis.ts:228"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"processoptions"},(0,t.yg)("a",{id:"process"}),(0,t.yg)("strong",{parentName:"h3"},"process"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Callback for ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze "),".\nDo the memory analysis and print results in this callback\nThe analysis should support:\n1) printing results on screen\n2) returning results via the return value"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | This is the auto-generated arguments passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"process")," method that your self-defined heap analysis should implement. You are not supposed to construct instances of this class."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"any"),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L216"},"heap-analysis/src/BaseAnalysis.ts:216"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/0ee6ea57.e5e89145.js b/assets/js/0ee6ea57.ed0b5255.js similarity index 96% rename from assets/js/0ee6ea57.e5e89145.js rename to assets/js/0ee6ea57.ed0b5255.js index 74405c82..b4a2fedc 100644 --- a/assets/js/0ee6ea57.e5e89145.js +++ b/assets/js/0ee6ea57.ed0b5255.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[4573],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),g=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):o(o({},a),e)),n},s=function(e){var a=g(e.components);return r.createElement(p.Provider,{value:a},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},m=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,i=e.originalType,p=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),d=g(n),m=t,y=d["".concat(p,".").concat(m)]||d[m]||c[m]||i;return n?r.createElement(y,o(o({ref:a},s),{},{components:n})):r.createElement(y,o({ref:a},s))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var p in a)hasOwnProperty.call(a,p)&&(l[p]=a[p]);l.originalType=e,l[d]="string"==typeof e?e:t,o[1]=l;for(var g=2;g{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>o,default:()=>c,frontMatter:()=>i,metadata:()=>l,toc:()=>g});var r=n(8168),t=(n(6540),n(5680));const i={id:"core_src.IHeapNode",title:"Interface: IHeapNode",sidebar_label:"IHeapNode",custom_edit_url:null},o=void 0,l={unversionedId:"api/interfaces/core_src.IHeapNode",id:"api/interfaces/core_src.IHeapNode",title:"Interface: IHeapNode",description:"An IHeapNode instance represents a JS heap object in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapNode.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapNode",title:"Interface: IHeapNode",sidebar_label:"IHeapNode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},next:{title:"IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes"}},p={},g=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' dominatorNode: Nullable<IHeapNode>',id:"-dominatornode-nullableiheapnode",level:3},{value:' edge_count: number',id:"-edge_count-number",level:3},{value:' hasPathEdge: boolean',id:"-haspathedge-boolean",level:3},{value:' id: number',id:"-id-number",level:3},{value:' isString: boolean',id:"-isstring-boolean",level:3},{value:' is_detached: boolean',id:"-is_detached-boolean",level:3},{value:' location: Nullable<IHeapLocation>',id:"-location-nullableiheaplocation",level:3},{value:' name: string',id:"-name-string",level:3},{value:' nodeIndex: number',id:"-nodeindex-number",level:3},{value:' numOfReferrers: number',id:"-numofreferrers-number",level:3},{value:' pathEdge: null | IHeapEdge',id:"-pathedge-null--iheapedge",level:3},{value:' references: IHeapEdge[]',id:"-references-iheapedge",level:3},{value:' referrers: IHeapEdge[]',id:"-referrers-iheapedge",level:3},{value:' retainedSize: number',id:"-retainedsize-number",level:3},{value:' self_size: number',id:"-self_size-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'findAnyReference(predicate)',id:"findanyreferencepredicate",level:3},{value:'findAnyReferrer(predicate)',id:"findanyreferrerpredicate",level:3},{value:'findAnyReferrerNode(predicate)',id:"findanyreferrernodepredicate",level:3},{value:'findReferrerNodes(predicate)',id:"findreferrernodespredicate",level:3},{value:'findReferrers(predicate)',id:"findreferrerspredicate",level:3},{value:'forEachReference(callback)',id:"foreachreferencecallback",level:3},{value:'forEachReferrer(callback)',id:"foreachreferrercallback",level:3},{value:'getAnyReferrer(edgeName, edgeType?)',id:"getanyreferreredgename-edgetype",level:3},{value:'getAnyReferrerNode(edgeName, edgeType?)',id:"getanyreferrernodeedgename-edgetype",level:3},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'getReference(edgeName, edgeType?)',id:"getreferenceedgename-edgetype",level:3},{value:'getReferenceNode(edgeName, edgeType?)',id:"getreferencenodeedgename-edgetype",level:3},{value:'getReferrerNodes(edgeName, edgeType?)',id:"getreferrernodesedgename-edgetype",level:3},{value:'getReferrers(edgeName, edgeType?)',id:"getreferrersedgename-edgetype",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3},{value:'toStringNode()',id:"tostringnode",level:3}],s={toc:g},d="wrapper";function c(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNode")," instance represents a JS heap object in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNode")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n // use the heap node APIs here\n const id = node.id;\n const type = node.type;\n // ...\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNodeBasic")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapNode"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-dominatornode-nullableiheapnode"},(0,t.yg)("a",{id:"dominatornode",name:"dominatornode"})," ",(0,t.yg)("strong",{parentName:"h3"},"dominatorNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,t.yg)("p",null,"get the dominator node of this node. If the dominator node gets released\nthere will be no path from GC to this node, and therefore this node can\nalso be released.\nFor more information on what a dominator node is, please check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#dominators"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1904"},"core/src/lib/Types.ts:1904"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-edge_count-number"},(0,t.yg)("a",{id:"edge\\_count",name:"edge\\_count"})," ",(0,t.yg)("strong",{parentName:"h3"},"edge","_","count"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of outgoing JS references (including engine-internal,\nnative, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1858"},"core/src/lib/Types.ts:1858"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-haspathedge-boolean"},(0,t.yg)("a",{id:"haspathedge",name:"haspathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"hasPathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"returns true if the heap node has been set an incoming edge\nwhich leads to the parent node on the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1880"},"core/src/lib/Types.ts:1880"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-id-number"},(0,t.yg)("a",{id:"id",name:"id"})," ",(0,t.yg)("strong",{parentName:"h3"},"id"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"unique id of the heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1785"},"core/src/lib/Types.ts:1785"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-isstring-boolean"},(0,t.yg)("a",{id:"isstring",name:"isstring"})," ",(0,t.yg)("strong",{parentName:"h3"},"isString"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"check if this a string node (normal string node, concatenated string node\nor sliced string node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1916"},"core/src/lib/Types.ts:1916"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_detached-boolean"},(0,t.yg)("a",{id:"is\\_detached",name:"is\\_detached"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","detached"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a DOM element and the DOM element is detached\nfrom the DOM tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a React Fiber node and the Fiber node is unmounted\nfrom the React Fiber tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";\notherwise it will be ",(0,t.yg)("inlineCode",{parentName:"p"},"false"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1840"},"core/src/lib/Types.ts:1840"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-location-nullableiheaplocation"},(0,t.yg)("a",{id:"location",name:"location"})," ",(0,t.yg)("strong",{parentName:"h3"},"location"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapLocation")),">"),(0,t.yg)("p",null,"source location information of this heap object (if it is recorded by\nthe heap snapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1909"},"core/src/lib/Types.ts:1909"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name-string"},(0,t.yg)("a",{id:"name",name:"name"})," ",(0,t.yg)("strong",{parentName:"h3"},"name"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"this is the ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," field associated with the heap object,\nfor JS object instances (type ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),"), ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the constructor's name\nof the object instance. for ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the string value."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1781"},"core/src/lib/Types.ts:1781"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-nodeindex-number"},(0,t.yg)("a",{id:"nodeindex",name:"nodeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"nodeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this heap object inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"node.snapshot.nodes")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1889"},"core/src/lib/Types.ts:1889"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-numofreferrers-number"},(0,t.yg)("a",{id:"numofreferrers",name:"numofreferrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"numOfReferrers"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"Get the number of all incoming references pointing to this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1875"},"core/src/lib/Types.ts:1875"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-pathedge-null--iheapedge"},(0,t.yg)("a",{id:"pathedge",name:"pathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"pathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))),(0,t.yg)("p",null,"The incoming edge which leads to the parent node\non the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1885"},"core/src/lib/Types.ts:1885"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-references-iheapedge"},(0,t.yg)("a",{id:"references",name:"references"})," ",(0,t.yg)("strong",{parentName:"h3"},"references"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all outgoing JS references from this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1865"},"core/src/lib/Types.ts:1865"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-referrers-iheapedge"},(0,t.yg)("a",{id:"referrers",name:"referrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"referrers"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all incoming JS references pointing to this heap\nobject (including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1870"},"core/src/lib/Types.ts:1870"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-retainedsize-number"},(0,t.yg)("a",{id:"retainedsize",name:"retainedsize"})," ",(0,t.yg)("strong",{parentName:"h3"},"retainedSize"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"retained size")," of the heap object (i.e., the total size of memory that\ncould be released if this object is released). For difference between\n",(0,t.yg)("strong",{parentName:"p"},"retained size")," and ",(0,t.yg)("strong",{parentName:"p"},"shallow size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1896"},"core/src/lib/Types.ts:1896"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-self_size-number"},(0,t.yg)("a",{id:"self\\_size",name:"self\\_size"})," ",(0,t.yg)("strong",{parentName:"h3"},"self","_","size"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"shallow size")," of the heap object (i.e., the size of memory that is held\nby the object itself.). For difference between ",(0,t.yg)("strong",{parentName:"p"},"shallow size")," and\n",(0,t.yg)("strong",{parentName:"p"},"retained size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1853"},"core/src/lib/Types.ts:1853"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1832"},"core/src/lib/Types.ts:1832"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"the type of the heap node object. All possible types:\nThis is engine-specific, for example all types in V8:\n",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"array"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"code"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"closure"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"regexp"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"native"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"synthetic"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"concatenated string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"sliced string"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"symbol"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"bigint")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1775"},"core/src/lib/Types.ts:1775"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"findanyreferencepredicate"},(0,t.yg)("a",{id:"findanyreference"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\nin the hosting node (or outgoing edges from the node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first outgoing edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const reference = node.findAnyReference((edge: IHeapEdge) => {\n // find the outgoing reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1997"},"core/src/lib/Types.ts:1997"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrerpredicate"},(0,t.yg)("a",{id:"findanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node) until the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first incoming edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrer((edge: IHeapEdge) => {\n // find the incoming reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2014"},"core/src/lib/Types.ts:2014"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrernodepredicate"},(0,t.yg)("a",{id:"findanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each incoming JavaScript heap object"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the first referring node for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such node is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrerNode((node: IHeapNode) => {\n // find the referring node with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2032"},"core/src/lib/Types.ts:2032"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrernodespredicate"},(0,t.yg)("a",{id:"findreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each referrer nodes"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing all the referrer nodes for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nnode is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrerNodes = node.findReferrerNodes((node: IHeapNode) => {\n // find all the referring nodes with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2067"},"core/src/lib/Types.ts:2067"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrerspredicate"},(0,t.yg)("a",{id:"findreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nedge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrers = node.findReferrers((edge: IHeapEdge) => {\n // find all the incoming references with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2049"},"core/src/lib/Types.ts:2049"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferencecallback"},(0,t.yg)("a",{id:"foreachreference"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference in the\nhosting node (or outgoing edges from the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReference((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.references list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1962"},"core/src/lib/Types.ts:1962"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferrercallback"},(0,t.yg)("a",{id:"foreachreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference pointing\nto the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReferrer((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.referrers list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1980"},"core/src/lib/Types.ts:1980"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferreredgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the incoming edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS reference named \"ref\" pointing to node\nconst reference = node.getAnyReferrer('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2122"},"core/src/lib/Types.ts:2122"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferrernodeedgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds one of the incoming JS\nreferences pointing to the hosting node, and returns the JS heap object\ncontaining the incoming reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node containing the incoming JS reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst n1 = node.getAnyReferrerNode('ref', 'property');\n// this is equivalent to\nconst n2 = node.getAnyReferrer('ref', 'property')?.fromNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2145"},"core/src/lib/Types.ts:2145"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1931"},"core/src/lib/Types.ts:1931"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferenceedgename-edgetype"},(0,t.yg)("a",{id:"getreference"}),(0,t.yg)("strong",{parentName:"h3"},"getReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an outgoing JS\nreference from the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the outgoing edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the internal reference to node's hidden class\nconst reference = node.getReference('map', 'hidden');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2082"},"core/src/lib/Types.ts:2082"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferencenodeedgename-edgetype"},(0,t.yg)("a",{id:"getreferencenode"}),(0,t.yg)("strong",{parentName:"h3"},"getReferenceNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds the outgoing JS\nreference from the hosting node, and returns the JS heap object pointed to\nby the outgoing JS reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node pointed to by the outgoing reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the node's hidden class\nconst hiddenClassNode = node.getReferenceNode('map', 'hidden');\n// this is equivalent to\nconst hiddenClassNode2 = node.getReference('map', 'hidden')?.toNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2104"},"core/src/lib/Types.ts:2104"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrernodesedgename-edgetype"},(0,t.yg)("a",{id:"getreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all of the incoming JS\nreferences pointing to the hosting node, and returns an array containing\nthe hosting node for each of the incoming JS references."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing the hosting nodes, with each node corresponds\nto each incoming JS reference that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst nodes1 = node.getReferrerNodes('ref', 'property');\n// this is equivalent to\nconst nodes2 = node.getReferrers('ref', 'property')\n .map(edge => edge.fromNode);\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2185"},"core/src/lib/Types.ts:2185"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrersedgename-edgetype"},(0,t.yg)("a",{id:"getreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all the incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges that\nmeet the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of of the JS reference named \"ref\" pointing to node\nconst referrers = node.getReferrers('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2164"},"core/src/lib/Types.ts:2164"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1944"},"core/src/lib/Types.ts:1944"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tostringnode"},(0,t.yg)("a",{id:"tostringnode"}),(0,t.yg)("strong",{parentName:"h3"},"toStringNode"),"()"),(0,t.yg)("p",null,"convert to an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object if this node is a string node.\nThe ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object supports querying the string content\ninside the string node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode")),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1922"},"core/src/lib/Types.ts:1922"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[4573],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),g=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):o(o({},a),e)),n},s=function(e){var a=g(e.components);return r.createElement(p.Provider,{value:a},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},m=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,i=e.originalType,p=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),d=g(n),m=t,y=d["".concat(p,".").concat(m)]||d[m]||c[m]||i;return n?r.createElement(y,o(o({ref:a},s),{},{components:n})):r.createElement(y,o({ref:a},s))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var p in a)hasOwnProperty.call(a,p)&&(l[p]=a[p]);l.originalType=e,l[d]="string"==typeof e?e:t,o[1]=l;for(var g=2;g{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>o,default:()=>c,frontMatter:()=>i,metadata:()=>l,toc:()=>g});var r=n(8168),t=(n(6540),n(5680));const i={id:"core_src.IHeapNode",title:"Interface: IHeapNode",sidebar_label:"IHeapNode",custom_edit_url:null},o=void 0,l={unversionedId:"api/interfaces/core_src.IHeapNode",id:"api/interfaces/core_src.IHeapNode",title:"Interface: IHeapNode",description:"An IHeapNode instance represents a JS heap object in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapNode.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapNode",title:"Interface: IHeapNode",sidebar_label:"IHeapNode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},next:{title:"IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes"}},p={},g=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' dominatorNode: Nullable<IHeapNode>',id:"-dominatornode-nullableiheapnode",level:3},{value:' edge_count: number',id:"-edge_count-number",level:3},{value:' hasPathEdge: boolean',id:"-haspathedge-boolean",level:3},{value:' id: number',id:"-id-number",level:3},{value:' isString: boolean',id:"-isstring-boolean",level:3},{value:' is_detached: boolean',id:"-is_detached-boolean",level:3},{value:' location: Nullable<IHeapLocation>',id:"-location-nullableiheaplocation",level:3},{value:' name: string',id:"-name-string",level:3},{value:' nodeIndex: number',id:"-nodeindex-number",level:3},{value:' numOfReferrers: number',id:"-numofreferrers-number",level:3},{value:' pathEdge: null | IHeapEdge',id:"-pathedge-null--iheapedge",level:3},{value:' references: IHeapEdge[]',id:"-references-iheapedge",level:3},{value:' referrers: IHeapEdge[]',id:"-referrers-iheapedge",level:3},{value:' retainedSize: number',id:"-retainedsize-number",level:3},{value:' self_size: number',id:"-self_size-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'findAnyReference(predicate)',id:"findanyreferencepredicate",level:3},{value:'findAnyReferrer(predicate)',id:"findanyreferrerpredicate",level:3},{value:'findAnyReferrerNode(predicate)',id:"findanyreferrernodepredicate",level:3},{value:'findReferrerNodes(predicate)',id:"findreferrernodespredicate",level:3},{value:'findReferrers(predicate)',id:"findreferrerspredicate",level:3},{value:'forEachReference(callback)',id:"foreachreferencecallback",level:3},{value:'forEachReferrer(callback)',id:"foreachreferrercallback",level:3},{value:'getAnyReferrer(edgeName, edgeType?)',id:"getanyreferreredgename-edgetype",level:3},{value:'getAnyReferrerNode(edgeName, edgeType?)',id:"getanyreferrernodeedgename-edgetype",level:3},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'getReference(edgeName, edgeType?)',id:"getreferenceedgename-edgetype",level:3},{value:'getReferenceNode(edgeName, edgeType?)',id:"getreferencenodeedgename-edgetype",level:3},{value:'getReferrerNodes(edgeName, edgeType?)',id:"getreferrernodesedgename-edgetype",level:3},{value:'getReferrers(edgeName, edgeType?)',id:"getreferrersedgename-edgetype",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3},{value:'toStringNode()',id:"tostringnode",level:3}],s={toc:g},d="wrapper";function c(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNode")," instance represents a JS heap object in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNode")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n // use the heap node APIs here\n const id = node.id;\n const type = node.type;\n // ...\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"IHeapNodeBasic")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapNode"))),(0,t.yg)("p",{parentName:"li"},"\u21b3\u21b3 ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-dominatornode-nullableiheapnode"},(0,t.yg)("a",{id:"dominatornode",name:"dominatornode"})," ",(0,t.yg)("strong",{parentName:"h3"},"dominatorNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,t.yg)("p",null,"get the dominator node of this node. If the dominator node gets released\nthere will be no path from GC to this node, and therefore this node can\nalso be released.\nFor more information on what a dominator node is, please check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#dominators"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1904"},"core/src/lib/Types.ts:1904"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-edge_count-number"},(0,t.yg)("a",{id:"edge\\_count",name:"edge\\_count"})," ",(0,t.yg)("strong",{parentName:"h3"},"edge","_","count"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of outgoing JS references (including engine-internal,\nnative, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1858"},"core/src/lib/Types.ts:1858"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-haspathedge-boolean"},(0,t.yg)("a",{id:"haspathedge",name:"haspathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"hasPathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"returns true if the heap node has been set an incoming edge\nwhich leads to the parent node on the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1880"},"core/src/lib/Types.ts:1880"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-id-number"},(0,t.yg)("a",{id:"id",name:"id"})," ",(0,t.yg)("strong",{parentName:"h3"},"id"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"unique id of the heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1785"},"core/src/lib/Types.ts:1785"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-isstring-boolean"},(0,t.yg)("a",{id:"isstring",name:"isstring"})," ",(0,t.yg)("strong",{parentName:"h3"},"isString"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"check if this a string node (normal string node, concatenated string node\nor sliced string node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1916"},"core/src/lib/Types.ts:1916"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_detached-boolean"},(0,t.yg)("a",{id:"is\\_detached",name:"is\\_detached"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","detached"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a DOM element and the DOM element is detached\nfrom the DOM tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a React Fiber node and the Fiber node is unmounted\nfrom the React Fiber tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";\notherwise it will be ",(0,t.yg)("inlineCode",{parentName:"p"},"false"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1840"},"core/src/lib/Types.ts:1840"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-location-nullableiheaplocation"},(0,t.yg)("a",{id:"location",name:"location"})," ",(0,t.yg)("strong",{parentName:"h3"},"location"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapLocation")),">"),(0,t.yg)("p",null,"source location information of this heap object (if it is recorded by\nthe heap snapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1909"},"core/src/lib/Types.ts:1909"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name-string"},(0,t.yg)("a",{id:"name",name:"name"})," ",(0,t.yg)("strong",{parentName:"h3"},"name"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"this is the ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," field associated with the heap object,\nfor JS object instances (type ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),"), ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the constructor's name\nof the object instance. for ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the string value."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1781"},"core/src/lib/Types.ts:1781"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-nodeindex-number"},(0,t.yg)("a",{id:"nodeindex",name:"nodeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"nodeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this heap object inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"node.snapshot.nodes")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1889"},"core/src/lib/Types.ts:1889"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-numofreferrers-number"},(0,t.yg)("a",{id:"numofreferrers",name:"numofreferrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"numOfReferrers"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"Get the number of all incoming references pointing to this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1875"},"core/src/lib/Types.ts:1875"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-pathedge-null--iheapedge"},(0,t.yg)("a",{id:"pathedge",name:"pathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"pathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))),(0,t.yg)("p",null,"The incoming edge which leads to the parent node\non the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1885"},"core/src/lib/Types.ts:1885"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-references-iheapedge"},(0,t.yg)("a",{id:"references",name:"references"})," ",(0,t.yg)("strong",{parentName:"h3"},"references"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all outgoing JS references from this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1865"},"core/src/lib/Types.ts:1865"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-referrers-iheapedge"},(0,t.yg)("a",{id:"referrers",name:"referrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"referrers"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all incoming JS references pointing to this heap\nobject (including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1870"},"core/src/lib/Types.ts:1870"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-retainedsize-number"},(0,t.yg)("a",{id:"retainedsize",name:"retainedsize"})," ",(0,t.yg)("strong",{parentName:"h3"},"retainedSize"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"retained size")," of the heap object (i.e., the total size of memory that\ncould be released if this object is released). For difference between\n",(0,t.yg)("strong",{parentName:"p"},"retained size")," and ",(0,t.yg)("strong",{parentName:"p"},"shallow size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1896"},"core/src/lib/Types.ts:1896"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-self_size-number"},(0,t.yg)("a",{id:"self\\_size",name:"self\\_size"})," ",(0,t.yg)("strong",{parentName:"h3"},"self","_","size"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"shallow size")," of the heap object (i.e., the size of memory that is held\nby the object itself.). For difference between ",(0,t.yg)("strong",{parentName:"p"},"shallow size")," and\n",(0,t.yg)("strong",{parentName:"p"},"retained size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1853"},"core/src/lib/Types.ts:1853"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1832"},"core/src/lib/Types.ts:1832"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"the type of the heap node object. All possible types:\nThis is engine-specific, for example all types in V8:\n",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"array"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"code"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"closure"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"regexp"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"native"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"synthetic"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"concatenated string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"sliced string"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"symbol"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"bigint")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1775"},"core/src/lib/Types.ts:1775"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"findanyreferencepredicate"},(0,t.yg)("a",{id:"findanyreference"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\nin the hosting node (or outgoing edges from the node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first outgoing edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const reference = node.findAnyReference((edge: IHeapEdge) => {\n // find the outgoing reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1997"},"core/src/lib/Types.ts:1997"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrerpredicate"},(0,t.yg)("a",{id:"findanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node) until the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first incoming edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrer((edge: IHeapEdge) => {\n // find the incoming reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2014"},"core/src/lib/Types.ts:2014"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrernodepredicate"},(0,t.yg)("a",{id:"findanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each incoming JavaScript heap object"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the first referring node for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such node is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrerNode((node: IHeapNode) => {\n // find the referring node with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2032"},"core/src/lib/Types.ts:2032"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrernodespredicate"},(0,t.yg)("a",{id:"findreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each referrer nodes"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing all the referrer nodes for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nnode is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrerNodes = node.findReferrerNodes((node: IHeapNode) => {\n // find all the referring nodes with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2067"},"core/src/lib/Types.ts:2067"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrerspredicate"},(0,t.yg)("a",{id:"findreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nedge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrers = node.findReferrers((edge: IHeapEdge) => {\n // find all the incoming references with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2049"},"core/src/lib/Types.ts:2049"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferencecallback"},(0,t.yg)("a",{id:"foreachreference"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference in the\nhosting node (or outgoing edges from the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReference((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.references list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1962"},"core/src/lib/Types.ts:1962"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferrercallback"},(0,t.yg)("a",{id:"foreachreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference pointing\nto the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReferrer((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.referrers list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1980"},"core/src/lib/Types.ts:1980"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferreredgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the incoming edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS reference named \"ref\" pointing to node\nconst reference = node.getAnyReferrer('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2122"},"core/src/lib/Types.ts:2122"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferrernodeedgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds one of the incoming JS\nreferences pointing to the hosting node, and returns the JS heap object\ncontaining the incoming reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node containing the incoming JS reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst n1 = node.getAnyReferrerNode('ref', 'property');\n// this is equivalent to\nconst n2 = node.getAnyReferrer('ref', 'property')?.fromNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2145"},"core/src/lib/Types.ts:2145"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1931"},"core/src/lib/Types.ts:1931"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferenceedgename-edgetype"},(0,t.yg)("a",{id:"getreference"}),(0,t.yg)("strong",{parentName:"h3"},"getReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an outgoing JS\nreference from the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the outgoing edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the internal reference to node's hidden class\nconst reference = node.getReference('map', 'hidden');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2082"},"core/src/lib/Types.ts:2082"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferencenodeedgename-edgetype"},(0,t.yg)("a",{id:"getreferencenode"}),(0,t.yg)("strong",{parentName:"h3"},"getReferenceNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds the outgoing JS\nreference from the hosting node, and returns the JS heap object pointed to\nby the outgoing JS reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node pointed to by the outgoing reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the node's hidden class\nconst hiddenClassNode = node.getReferenceNode('map', 'hidden');\n// this is equivalent to\nconst hiddenClassNode2 = node.getReference('map', 'hidden')?.toNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2104"},"core/src/lib/Types.ts:2104"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrernodesedgename-edgetype"},(0,t.yg)("a",{id:"getreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all of the incoming JS\nreferences pointing to the hosting node, and returns an array containing\nthe hosting node for each of the incoming JS references."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing the hosting nodes, with each node corresponds\nto each incoming JS reference that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst nodes1 = node.getReferrerNodes('ref', 'property');\n// this is equivalent to\nconst nodes2 = node.getReferrers('ref', 'property')\n .map(edge => edge.fromNode);\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2185"},"core/src/lib/Types.ts:2185"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrersedgename-edgetype"},(0,t.yg)("a",{id:"getreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all the incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges that\nmeet the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of of the JS reference named \"ref\" pointing to node\nconst referrers = node.getReferrers('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2164"},"core/src/lib/Types.ts:2164"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1944"},"core/src/lib/Types.ts:1944"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tostringnode"},(0,t.yg)("a",{id:"tostringnode"}),(0,t.yg)("strong",{parentName:"h3"},"toStringNode"),"()"),(0,t.yg)("p",null,"convert to an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object if this node is a string node.\nThe ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object supports querying the string content\ninside the string node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode")),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1922"},"core/src/lib/Types.ts:1922"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/1bb76b7a.6e511fc9.js b/assets/js/1bb76b7a.ffb915e4.js similarity index 93% rename from assets/js/1bb76b7a.6e511fc9.js rename to assets/js/1bb76b7a.ffb915e4.js index 89210f12..ef9b9e00 100644 --- a/assets/js/1bb76b7a.6e511fc9.js +++ b/assets/js/1bb76b7a.ffb915e4.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2915],{5680:(e,a,n)=>{n.d(a,{xA:()=>p,yg:()=>d});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function r(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),y=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},p=function(e){var a=y(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},m=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,r=e.originalType,o=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),c=y(n),m=s,d=c["".concat(o,".").concat(m)]||c[m]||u[m]||r;return n?t.createElement(d,l(l({ref:a},p),{},{components:n})):t.createElement(d,l({ref:a},p))}));function d(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var r=n.length,l=new Array(r);l[0]=m;var i={};for(var o in a)hasOwnProperty.call(a,o)&&(i[o]=a[o]);i.originalType=e,i[c]="string"==typeof e?e:s,l[1]=i;for(var y=2;y{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>l,default:()=>u,frontMatter:()=>r,metadata:()=>i,toc:()=>y});var t=n(8168),s=(n(6540),n(5680));const r={id:"heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",sidebar_label:"ObjectUnboundGrowthAnalysis",custom_edit_url:null},l=void 0,i={unversionedId:"api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",id:"api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",sidebar_label:"ObjectUnboundGrowthAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},next:{title:"ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"}},o={},y=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectUnboundGrowthAnalysis()',id:"new-objectunboundgrowthanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],p={toc:y},c="wrapper";function u(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},p,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectUnboundGrowthAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectunboundgrowthanalysis"},(0,s.yg)("a",{id:"new objectunboundgrowthanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectUnboundGrowthAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,s.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectUnboundGrowthAnalysis.ts#L33"},"heap-analysis/src/plugins/ObjectUnboundGrowthAnalysis.ts:33"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2915],{5680:(e,a,n)=>{n.d(a,{xA:()=>p,yg:()=>m});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function r(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),y=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},p=function(e){var a=y(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},d=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,r=e.originalType,o=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),c=y(n),d=s,m=c["".concat(o,".").concat(d)]||c[d]||u[d]||r;return n?t.createElement(m,l(l({ref:a},p),{},{components:n})):t.createElement(m,l({ref:a},p))}));function m(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var r=n.length,l=new Array(r);l[0]=d;var i={};for(var o in a)hasOwnProperty.call(a,o)&&(i[o]=a[o]);i.originalType=e,i[c]="string"==typeof e?e:s,l[1]=i;for(var y=2;y{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>l,default:()=>u,frontMatter:()=>r,metadata:()=>i,toc:()=>y});var t=n(8168),s=(n(6540),n(5680));const r={id:"heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",sidebar_label:"ObjectUnboundGrowthAnalysis",custom_edit_url:null},l=void 0,i={unversionedId:"api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",id:"api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectUnboundGrowthAnalysis",title:"Class: ObjectUnboundGrowthAnalysis",sidebar_label:"ObjectUnboundGrowthAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},next:{title:"ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"}},o={},y=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectUnboundGrowthAnalysis()',id:"new-objectunboundgrowthanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],p={toc:y},c="wrapper";function u(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},p,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectUnboundGrowthAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectunboundgrowthanalysis"},(0,s.yg)("a",{id:"new objectunboundgrowthanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectUnboundGrowthAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,s.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectUnboundGrowthAnalysis.ts#L33"},"heap-analysis/src/plugins/ObjectUnboundGrowthAnalysis.ts:33"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/26eba521.ce8dcbb8.js b/assets/js/26eba521.ab50ddbe.js similarity index 97% rename from assets/js/26eba521.ce8dcbb8.js rename to assets/js/26eba521.ab50ddbe.js index 0f91589d..3282a668 100644 --- a/assets/js/26eba521.ce8dcbb8.js +++ b/assets/js/26eba521.ab50ddbe.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6571],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=t.createContext({}),g=function(e){var a=t.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},s=function(e){var a=g(e.components);return t.createElement(p.Provider,{value:a},e.children)},m="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},c=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),m=g(n),c=r,y=m["".concat(p,".").concat(c)]||m[c]||d[c]||l;return n?t.createElement(y,i(i({ref:a},s),{},{components:n})):t.createElement(y,i({ref:a},s))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=c;var o={};for(var p in a)hasOwnProperty.call(a,p)&&(o[p]=a[p]);o.originalType=e,o[m]="string"==typeof e?e:r,i[1]=o;for(var g=2;g{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>l,metadata:()=>o,toc:()=>g});var t=n(8168),r=(n(6540),n(5680));const l={id:"core_src",title:"Package: @memlab/core",sidebar_label:"core/src",sidebar_position:0,custom_edit_url:null},i=void 0,o={unversionedId:"api/modules/core_src",id:"api/modules/core_src",title:"Package: @memlab/core",description:"Interfaces",source:"@site/docs/api/modules/core_src.md",sourceDirName:"api/modules",slug:"/api/modules/core_src",permalink:"/memlab/docs/api/modules/core_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"core_src",title:"Package: @memlab/core",sidebar_label:"core/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"api/src",permalink:"/memlab/docs/api/modules/api_src"},next:{title:"heap-analysis/src",permalink:"/memlab/docs/api/modules/heap_analysis_src"}},p={},g=[{value:"Interfaces",id:"interfaces",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' CheckPageLoadCallback: (page: Page) => Promise<boolean>',id:"-checkpageloadcallback-page-page--promiseboolean",level:3},{value:' Cookie: Object',id:"-cookie-object",level:3},{value:' Cookies: Cookie[]',id:"-cookies-cookie",level:3},{value:' EdgeIterationCallback: (edge: IHeapEdge) => Optional<{ stop: boolean }> | void',id:"-edgeiterationcallback-edge-iheapedge--optional-stop-boolean----void",level:3},{value:' InitLeakFilterCallback: (snapshot: IHeapSnapshot, leakedNodeIds: HeapNodeIdSet) => void',id:"-initleakfiltercallback-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--void",level:3},{value:' InteractionsCallback: (page: Page, args?: OperationArgs) => Promise<void>',id:"-interactionscallback-page-page-args-operationargs--promisevoid",level:3},{value:' LeakFilterCallback: (node: IHeapNode, snapshot: IHeapSnapshot, leakedNodeIds: HeapNodeIdSet) => boolean',id:"-leakfiltercallback-node-iheapnode-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--boolean",level:3},{value:' Nullable<T>: T | null',id:"-nullablet-t--null",level:3},{value:"Type parameters",id:"type-parameters",level:4},{value:' Optional<T>: T | null | undefined',id:"-optionalt-t--null--undefined",level:3},{value:"Type parameters",id:"type-parameters-1",level:4},{value:' Page: PuppeteerPage',id:"-page-puppeteerpage",level:3},{value:' Predicator<T>: (entity: T) => boolean',id:"-predicatort-entity-t--boolean",level:3},{value:"Type parameters",id:"type-parameters-2",level:4},{value:' ReferenceFilterCallback: (edge: IHeapEdge, snapshot: IHeapSnapshot, isReferenceUsedByDefault: boolean) => boolean',id:"-referencefiltercallback-edge-iheapedge-snapshot-iheapsnapshot-isreferenceusedbydefault-boolean--boolean",level:3},{value:' RunMetaInfo: Object',id:"-runmetainfo-object",level:3},{value:' Undefinable<T>: T | undefined',id:"-undefinablet-t--undefined",level:3},{value:"Type parameters",id:"type-parameters-3",level:4},{value:"Functions",id:"functions",level:2},{value:'dumpNodeHeapSnapshot()',id:"dumpnodeheapsnapshot",level:3},{value:'tagObject<T>(o, tag)',id:"tagobjectto-tag",level:3},{value:"Type parameters",id:"type-parameters-4",level:4},{value:'takeNodeMinimalHeap()',id:"takenodeminimalheap",level:3}],s={toc:g},m="wrapper";function d(e){let{components:a,...n}=e;return(0,r.yg)(m,(0,t.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("h2",{id:"interfaces"},"Interfaces"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},"IBrowserInfo")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},"IHeapEdges")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},"IHeapLocation")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},"IHeapNodes")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter"},"ILeakFilter")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IScenario"},"IScenario"))),(0,r.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,r.yg)("h3",{id:"-checkpageloadcallback-page-page--promiseboolean"},(0,r.yg)("a",{id:"checkpageloadcallback",name:"checkpageloadcallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"CheckPageLoadCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"page"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean"),">"),(0,r.yg)("p",null,"Callback function to provide if the page is loaded.\nFor concrete example, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#ispageloaded"},"isPageLoaded"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," | puppeteer's ",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page/"},"Page")," object. To import this type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"boolean"),">"," | a boolean value, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),", memlab will consider\nthe navigation completes, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"false"),", memlab will keep calling\nthis callback until it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),". This is an async callback, you can\nalso ",(0,r.yg)("inlineCode",{parentName:"p"},"await")," and returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," until some async logic is resolved.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1166"},"core/src/lib/Types.ts:1166"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-cookie-object"},(0,r.yg)("a",{id:"cookie",name:"cookie"})," ",(0,r.yg)("strong",{parentName:"h3"},"Cookie"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"A single cookie entry in a Cookies list.\nThe ",(0,r.yg)("inlineCode",{parentName:"p"},"name")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"value")," field is mandatory.\nIt is better to also specify the ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field, otherwise MemLab\nwill try to infer ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," automatically.\nThe other fields are optional.\nFor concrete use case, please check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),"."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"domain?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Add when possible: Defines the domain associated with the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"expires?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"number"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Indicates when the cookie will expire, in Unix time (seconds)")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"httpOnly?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to determine if the cookie is accessible only over HTTP")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"name")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Mandatory: Represents the name of the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"path?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Defines the domain associated with the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"sameSite?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},'"Strict"')," ","|"," ",(0,r.yg)("inlineCode",{parentName:"td"},'"Lax"'),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Determines if a cookie is transmitted with cross-site requests, offering a degree of defense against cross-site request forgery attacks.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"secure?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to indicate if the cookie transmission requires a secure protocol (e.g., HTTPS)")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"session?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to check if the cookie is a session cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"url?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Specifies the request-URI linked with the cookie setup. This can influence the cookie's default domain and path")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"value")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Mandatory: Represents the value assigned to the cookie")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L236"},"core/src/lib/Types.ts:236"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-cookies-cookie"},(0,r.yg)("a",{id:"cookies",name:"cookies"})," ",(0,r.yg)("strong",{parentName:"h3"},"Cookies"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#cookie"},(0,r.yg)("inlineCode",{parentName:"a"},"Cookie")),"[]"),(0,r.yg)("p",null,"Data structure for holding cookies.\nFor concrete use case, please check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L226"},"core/src/lib/Types.ts:226"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-edgeiterationcallback-edge-iheapedge--optional-stop-boolean----void"},(0,r.yg)("a",{id:"edgeiterationcallback",name:"edgeiterationcallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"EdgeIterationCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"edge"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),") => ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#optional"},(0,r.yg)("inlineCode",{parentName:"a"},"Optional")),"<{ ",(0,r.yg)("inlineCode",{parentName:"h3"},"stop"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")," }",">"," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"void")),(0,r.yg)("p",null,"Executes a provided callback once for JavaScript references.\nFor concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#foreachreference"},"forEachReference"),"\nor ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#foreachreferrer"},"forEachReferrer"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#optional"},(0,r.yg)("inlineCode",{parentName:"a"},"Optional")),"<{ ",(0,r.yg)("inlineCode",{parentName:"p"},"stop"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," }",">"," ","|"," ",(0,r.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1795"},"core/src/lib/Types.ts:1795"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-initleakfiltercallback-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--void"},(0,r.yg)("a",{id:"initleakfiltercallback",name:"initleakfiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"InitLeakFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"HeapNodeIdSet"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"void")),(0,r.yg)("p",null,"Lifecycle function callback that is invoked initially once before calling any\nleak filter function.\nFor concrete example, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#beforeleakfilter"},"beforeLeakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | heap snapshot see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"HeapNodeIdSet")," | the set of leaked object (node) ids."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"void"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L554"},"core/src/lib/Types.ts:554"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-interactionscallback-page-page-args-operationargs--promisevoid"},(0,r.yg)("a",{id:"interactionscallback",name:"interactionscallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"InteractionsCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"page"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"args?"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"OperationArgs"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"void"),">"),(0,r.yg)("p",null,"The callback defines browser interactions which are\nused by memlab to interact with the web app under test.\nFor concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#action"},"action")," or ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#back"},"back"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," | the puppeteer ",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," object, which provides APIs to interact with the web browser. To import this type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"args?"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"OperationArgs")))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"void"),">"," | no return value")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L640"},"core/src/lib/Types.ts:640"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-leakfiltercallback-node-iheapnode-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--boolean"},(0,r.yg)("a",{id:"leakfiltercallback",name:"leakfiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"LeakFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"node"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"HeapNodeIdSet"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("p",null,"Callback that can be used to define a logic to filter the\nleaked objects. The callback is only called for every node\nallocated but not released from the target interaction\nin the heap snapshot."),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode"))," | the node that is kept alive in the memory in the heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | the snapshot of target interaction"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"HeapNodeIdSet")," | the set of leaked node ids"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | the value indicating whether the given node in the snapshot\nshould be considered as leaked."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// any node in the heap snapshot that is greater than 1MB\nfunction leakFilter(node, _snapshot, _leakedNodeIds) {\n return node.retainedSize > 1000000;\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L581"},"core/src/lib/Types.ts:581"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-nullablet-t--null"},(0,r.yg)("a",{id:"nullable",name:"nullable"})," ",(0,r.yg)("strong",{parentName:"h3"},"Nullable"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"null")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"null")),(0,r.yg)("h4",{id:"type-parameters"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made nullable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L32"},"core/src/lib/Types.ts:32"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optionalt-t--null--undefined"},(0,r.yg)("a",{id:"optional",name:"optional"})," ",(0,r.yg)("strong",{parentName:"h3"},"Optional"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"undefined")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", ",(0,r.yg)("inlineCode",{parentName:"p"},"null"),", and ",(0,r.yg)("inlineCode",{parentName:"p"},"undefined"),"."),(0,r.yg)("h4",{id:"type-parameters-1"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made both nullable and undefinable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L38"},"core/src/lib/Types.ts:38"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-page-puppeteerpage"},(0,r.yg)("a",{id:"page",name:"page"})," ",(0,r.yg)("strong",{parentName:"h3"},"Page"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"PuppeteerPage")),(0,r.yg)("p",null,"This is the puppeteer ",(0,r.yg)("a",{parentName:"p",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nclass used by MemLab. The puppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," class instance provides\nAPIs to interact with the web browser."),(0,r.yg)("p",null,"The puppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," type can be incompatible across different versions.\nYour local npm-installed puppeteer version may be different from\nthe puppeteer used by MemLab. This may cause some type errors, for example:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {Page} from 'puppeteer';\nimport type {RunOptions} from '@memlab/api';\n\nconst runOptions: RunOptions = {\n scenario: {\n // initial page load url: Google Maps\n url: () => {\n return \"https://www.google.com/maps/@37.386427,-122.0428214,11z\";\n },\n // type error here if your local puppeeter version is different\n // from the puppeteer used by MemLab\n action: async function (page: Page) {\n await page.click('button[aria-label=\"Hotels\"]');\n },\n },\n};\n")),(0,r.yg)("p",null,"To avoid the type error in the code example above, MemLab exports the\npuppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," type used by MemLab so that your code can import it\nwhen necessary:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {Page} from '@memlab/core' // import Page type from memlab\nimport type {RunOptions} from 'memlab';\n\nconst runOptions: RunOptions = {\n scenario: {\n // initial page load url: Google Maps\n url: () => {\n return \"https://www.google.com/maps/@37.386427,-122.0428214,11z\";\n },\n // no type error here\n action: async function (page: Page) {\n await page.click('button[aria-label=\"Hotels\"]');\n },\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L207"},"core/src/lib/Types.ts:207"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-predicatort-entity-t--boolean"},(0,r.yg)("a",{id:"predicator",name:"predicator"})," ",(0,r.yg)("strong",{parentName:"h3"},"Predicator"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": (",(0,r.yg)("inlineCode",{parentName:"h3"},"entity"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("h4",{id:"type-parameters-2"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"the type of the entity to be checked")))),(0,r.yg)("p",null,"the predicate callback is used to decide if a\nentity of type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),".\nFor more concrete examples on where it is used,\ncheck out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findanyreference"},"findAnyReference"),", ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findanyreferrer"},"findAnyReferrer"),",\nand ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findreferrers"},"findReferrers"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"entity"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | the entity to be checked"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | whether the entity passes the predicate check")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L220"},"core/src/lib/Types.ts:220"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-referencefiltercallback-edge-iheapedge-snapshot-iheapsnapshot-isreferenceusedbydefault-boolean--boolean"},(0,r.yg)("a",{id:"referencefiltercallback",name:"referencefiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"ReferenceFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"edge"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be filtered (included) for some\ncalculations (e.g., retainer trace calculation)"),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))," | the reference (edge) that is considered for calcualting the retainer trace"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | the final snapshot taken after all browser interactions are done."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default logic for whether a reference should be filtered (included), if this parameter is true, it means MemLab will consider this reference for inclusion"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | the value indicating whether the given reference should be\nfiltered (i.e., included)")),(0,r.yg)("p",null,"Please also be aware that some edges like self-referencing edges,\nJS engine's internal edges, and hidden edges should not be considered\nas part of the retainer trace. These edges could make the retainer trace\nunncessarily complex and cause confusion. ",(0,r.yg)("inlineCode",{parentName:"p"},"isReferenceUsedByDefault")," will\nbe ",(0,r.yg)("inlineCode",{parentName:"p"},"false")," for these types of edges."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// exclude react fiber references\nfunction retainerReferenceFilter(edge, _snapshot, _isReferenceUsedByDefault) {\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n // exclude other references here\n // ...\n return true;\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L624"},"core/src/lib/Types.ts:624"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-runmetainfo-object"},(0,r.yg)("a",{id:"runmetainfo",name:"runmetainfo"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunMetaInfo"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"This data structure holds the information about memlab run.\nYou can retrieve the instance of this type through ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader#getrunmetainfo"},"getRunMetaInfo"),"."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"browserInfo")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},(0,r.yg)("inlineCode",{parentName:"a"},"IBrowserInfo"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"input configuration for the browser and output data from the browser")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"type")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"type of the memlab run")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1247"},"core/src/lib/Types.ts:1247"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-undefinablet-t--undefined"},(0,r.yg)("a",{id:"undefinable",name:"undefinable"})," ",(0,r.yg)("strong",{parentName:"h3"},"Undefinable"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"undefined")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"undefined"),"."),(0,r.yg)("h4",{id:"type-parameters-3"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made undefinable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L44"},"core/src/lib/Types.ts:44"))))),(0,r.yg)("h2",{id:"functions"},"Functions"),(0,r.yg)("h3",{id:"dumpnodeheapsnapshot"},(0,r.yg)("a",{id:"dumpnodeheapsnapshot"}),(0,r.yg)("strong",{parentName:"h3"},"dumpNodeHeapSnapshot"),"()"),(0,r.yg)("p",null,"Take a heap snapshot of the current program state and save it as a\n",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file under a randomly generated folder inside the system's\ntemp folder."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},"Note"),": All ",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," files could also be loaded by Chrome DevTools."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"string")," | the absolute file path to the saved ",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/NodeHeap.ts#L84"},"core/src/lib/NodeHeap.ts:84"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"tagobjectto-tag"},(0,r.yg)("a",{id:"tagobject"}),(0,r.yg)("strong",{parentName:"h3"},"tagObject"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">","(",(0,r.yg)("inlineCode",{parentName:"h3"},"o"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"tag"),")"),(0,r.yg)("p",null,"Tags a string marker to an object instance, which can later be checked by\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot#hasobjectwithtag"},"hasObjectWithTag"),". This API does not modify the object instance in\nany way (e.g., no additional or hidden properties added to the tagged\nobject)."),(0,r.yg)("h4",{id:"type-parameters-4"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"extends ",(0,r.yg)("inlineCode",{parentName:"td"},"object"))))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"o"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | specify the object instance you want to tag, you cannot tag a ",(0,r.yg)("a",{parentName:"li",href:"https://developer.mozilla.org/en-US/docs/Glossary/Primitive"},"primitive"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"tag"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | marker name to tag on the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | returns the tagged object instance (same reference as\nthe input argument ",(0,r.yg)("inlineCode",{parentName:"li"},"o"),")"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, AnyValue} from '@memlab/core';\nimport {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';\n\ntest('memory test', async () => {\n config.muteConsole = true;\n const o1: AnyValue = {};\n let o2: AnyValue = {};\n\n // tag o1 with marker: \"memlab-mark-1\", does not modify o1 in any way\n tagObject(o1, 'memlab-mark-1');\n // tag o2 with marker: \"memlab-mark-2\", does not modify o2 in any way\n tagObject(o2, 'memlab-mark-2');\n\n o2 = null;\n\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // expect object with marker \"memlab-mark-1\" exists\n expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);\n\n // expect object with marker \"memlab-mark-2\" can be GCed\n expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/NodeHeap.ts#L59"},"core/src/lib/NodeHeap.ts:59"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"takenodeminimalheap"},(0,r.yg)("a",{id:"takenodeminimalheap"}),(0,r.yg)("strong",{parentName:"h3"},"takeNodeMinimalHeap"),"()"),(0,r.yg)("p",null,"Take a heap snapshot of the current program state\nand parse it as ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),". Notice that\nthis API does not calculate some heap analysis meta data\nfor heap analysis. But this also means faster heap parsing."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),">"," | heap representation without heap analysis meta data.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples:")))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {takeNodeMinimalHeap} from '@memlab/core';\n\n(async function () {\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n})();\n")),(0,r.yg)("p",null,"If you need to get the heap snapshot with heap analysis meta data, please\nuse ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/NodeHeap.ts#L152"},"core/src/lib/NodeHeap.ts:152"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6571],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=t.createContext({}),g=function(e){var a=t.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},s=function(e){var a=g(e.components);return t.createElement(p.Provider,{value:a},e.children)},m="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},c=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),m=g(n),c=r,y=m["".concat(p,".").concat(c)]||m[c]||d[c]||l;return n?t.createElement(y,i(i({ref:a},s),{},{components:n})):t.createElement(y,i({ref:a},s))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=c;var o={};for(var p in a)hasOwnProperty.call(a,p)&&(o[p]=a[p]);o.originalType=e,o[m]="string"==typeof e?e:r,i[1]=o;for(var g=2;g{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>l,metadata:()=>o,toc:()=>g});var t=n(8168),r=(n(6540),n(5680));const l={id:"core_src",title:"Package: @memlab/core",sidebar_label:"core/src",sidebar_position:0,custom_edit_url:null},i=void 0,o={unversionedId:"api/modules/core_src",id:"api/modules/core_src",title:"Package: @memlab/core",description:"Interfaces",source:"@site/docs/api/modules/core_src.md",sourceDirName:"api/modules",slug:"/api/modules/core_src",permalink:"/memlab/docs/api/modules/core_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"core_src",title:"Package: @memlab/core",sidebar_label:"core/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"api/src",permalink:"/memlab/docs/api/modules/api_src"},next:{title:"heap-analysis/src",permalink:"/memlab/docs/api/modules/heap_analysis_src"}},p={},g=[{value:"Interfaces",id:"interfaces",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' CheckPageLoadCallback: (page: Page) => Promise<boolean>',id:"-checkpageloadcallback-page-page--promiseboolean",level:3},{value:' Cookie: Object',id:"-cookie-object",level:3},{value:' Cookies: Cookie[]',id:"-cookies-cookie",level:3},{value:' EdgeIterationCallback: (edge: IHeapEdge) => Optional<{ stop: boolean }> | void',id:"-edgeiterationcallback-edge-iheapedge--optional-stop-boolean----void",level:3},{value:' InitLeakFilterCallback: (snapshot: IHeapSnapshot, leakedNodeIds: HeapNodeIdSet) => void',id:"-initleakfiltercallback-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--void",level:3},{value:' InteractionsCallback: (page: Page, args?: OperationArgs) => Promise<void>',id:"-interactionscallback-page-page-args-operationargs--promisevoid",level:3},{value:' LeakFilterCallback: (node: IHeapNode, snapshot: IHeapSnapshot, leakedNodeIds: HeapNodeIdSet) => boolean',id:"-leakfiltercallback-node-iheapnode-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--boolean",level:3},{value:' Nullable<T>: T | null',id:"-nullablet-t--null",level:3},{value:"Type parameters",id:"type-parameters",level:4},{value:' Optional<T>: T | null | undefined',id:"-optionalt-t--null--undefined",level:3},{value:"Type parameters",id:"type-parameters-1",level:4},{value:' Page: PuppeteerPage',id:"-page-puppeteerpage",level:3},{value:' Predicator<T>: (entity: T) => boolean',id:"-predicatort-entity-t--boolean",level:3},{value:"Type parameters",id:"type-parameters-2",level:4},{value:' ReferenceFilterCallback: (edge: IHeapEdge, snapshot: IHeapSnapshot, isReferenceUsedByDefault: boolean) => boolean',id:"-referencefiltercallback-edge-iheapedge-snapshot-iheapsnapshot-isreferenceusedbydefault-boolean--boolean",level:3},{value:' RunMetaInfo: Object',id:"-runmetainfo-object",level:3},{value:' Undefinable<T>: T | undefined',id:"-undefinablet-t--undefined",level:3},{value:"Type parameters",id:"type-parameters-3",level:4},{value:"Functions",id:"functions",level:2},{value:'dumpNodeHeapSnapshot()',id:"dumpnodeheapsnapshot",level:3},{value:'tagObject<T>(o, tag)',id:"tagobjectto-tag",level:3},{value:"Type parameters",id:"type-parameters-4",level:4},{value:'takeNodeMinimalHeap()',id:"takenodeminimalheap",level:3}],s={toc:g},m="wrapper";function d(e){let{components:a,...n}=e;return(0,r.yg)(m,(0,t.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("h2",{id:"interfaces"},"Interfaces"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},"IBrowserInfo")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},"IHeapEdges")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},"IHeapLocation")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},"IHeapNodes")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter"},"ILeakFilter")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IScenario"},"IScenario"))),(0,r.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,r.yg)("h3",{id:"-checkpageloadcallback-page-page--promiseboolean"},(0,r.yg)("a",{id:"checkpageloadcallback",name:"checkpageloadcallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"CheckPageLoadCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"page"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean"),">"),(0,r.yg)("p",null,"Callback function to provide if the page is loaded.\nFor concrete example, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#ispageloaded"},"isPageLoaded"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," | puppeteer's ",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page/"},"Page")," object. To import this type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"boolean"),">"," | a boolean value, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),", memlab will consider\nthe navigation completes, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"false"),", memlab will keep calling\nthis callback until it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),". This is an async callback, you can\nalso ",(0,r.yg)("inlineCode",{parentName:"p"},"await")," and returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," until some async logic is resolved.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1166"},"core/src/lib/Types.ts:1166"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-cookie-object"},(0,r.yg)("a",{id:"cookie",name:"cookie"})," ",(0,r.yg)("strong",{parentName:"h3"},"Cookie"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"A single cookie entry in a Cookies list.\nThe ",(0,r.yg)("inlineCode",{parentName:"p"},"name")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"value")," field is mandatory.\nIt is better to also specify the ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field, otherwise MemLab\nwill try to infer ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," automatically.\nThe other fields are optional.\nFor concrete use case, please check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),"."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"domain?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Add when possible: Defines the domain associated with the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"expires?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"number"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Indicates when the cookie will expire, in Unix time (seconds)")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"httpOnly?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to determine if the cookie is accessible only over HTTP")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"name")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Mandatory: Represents the name of the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"path?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Defines the domain associated with the cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"sameSite?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},'"Strict"')," ","|"," ",(0,r.yg)("inlineCode",{parentName:"td"},'"Lax"'),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Determines if a cookie is transmitted with cross-site requests, offering a degree of defense against cross-site request forgery attacks.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"secure?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to indicate if the cookie transmission requires a secure protocol (e.g., HTTPS)")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"session?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"boolean"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Flag to check if the cookie is a session cookie")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"url?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/modules/core_src#undefinable"},(0,r.yg)("inlineCode",{parentName:"a"},"Undefinable")),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"Optional: Specifies the request-URI linked with the cookie setup. This can influence the cookie's default domain and path")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"value")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"Mandatory: Represents the value assigned to the cookie")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L236"},"core/src/lib/Types.ts:236"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-cookies-cookie"},(0,r.yg)("a",{id:"cookies",name:"cookies"})," ",(0,r.yg)("strong",{parentName:"h3"},"Cookies"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#cookie"},(0,r.yg)("inlineCode",{parentName:"a"},"Cookie")),"[]"),(0,r.yg)("p",null,"Data structure for holding cookies.\nFor concrete use case, please check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L226"},"core/src/lib/Types.ts:226"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-edgeiterationcallback-edge-iheapedge--optional-stop-boolean----void"},(0,r.yg)("a",{id:"edgeiterationcallback",name:"edgeiterationcallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"EdgeIterationCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"edge"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),") => ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#optional"},(0,r.yg)("inlineCode",{parentName:"a"},"Optional")),"<{ ",(0,r.yg)("inlineCode",{parentName:"h3"},"stop"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")," }",">"," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"void")),(0,r.yg)("p",null,"Executes a provided callback once for JavaScript references.\nFor concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#foreachreference"},"forEachReference"),"\nor ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#foreachreferrer"},"forEachReferrer"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#optional"},(0,r.yg)("inlineCode",{parentName:"a"},"Optional")),"<{ ",(0,r.yg)("inlineCode",{parentName:"p"},"stop"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," }",">"," ","|"," ",(0,r.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1795"},"core/src/lib/Types.ts:1795"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-initleakfiltercallback-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--void"},(0,r.yg)("a",{id:"initleakfiltercallback",name:"initleakfiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"InitLeakFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"HeapNodeIdSet"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"void")),(0,r.yg)("p",null,"Lifecycle function callback that is invoked initially once before calling any\nleak filter function.\nFor concrete example, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#beforeleakfilter"},"beforeLeakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | heap snapshot see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"HeapNodeIdSet")," | the set of leaked object (node) ids."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"void"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L554"},"core/src/lib/Types.ts:554"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-interactionscallback-page-page-args-operationargs--promisevoid"},(0,r.yg)("a",{id:"interactionscallback",name:"interactionscallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"InteractionsCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"page"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"args?"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"OperationArgs"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"void"),">"),(0,r.yg)("p",null,"The callback defines browser interactions which are\nused by memlab to interact with the web app under test.\nFor concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#action"},"action")," or ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#back"},"back"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," | the puppeteer ",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page"))," object, which provides APIs to interact with the web browser. To import this type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"args?"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"OperationArgs")))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"void"),">"," | no return value")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L640"},"core/src/lib/Types.ts:640"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-leakfiltercallback-node-iheapnode-snapshot-iheapsnapshot-leakednodeids-heapnodeidset--boolean"},(0,r.yg)("a",{id:"leakfiltercallback",name:"leakfiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"LeakFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"node"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"HeapNodeIdSet"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("p",null,"Callback that can be used to define a logic to filter the\nleaked objects. The callback is only called for every node\nallocated but not released from the target interaction\nin the heap snapshot."),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode"))," | the node that is kept alive in the memory in the heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | the snapshot of target interaction"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"HeapNodeIdSet")," | the set of leaked node ids"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | the value indicating whether the given node in the snapshot\nshould be considered as leaked."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// any node in the heap snapshot that is greater than 1MB\nfunction leakFilter(node, _snapshot, _leakedNodeIds) {\n return node.retainedSize > 1000000;\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L581"},"core/src/lib/Types.ts:581"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-nullablet-t--null"},(0,r.yg)("a",{id:"nullable",name:"nullable"})," ",(0,r.yg)("strong",{parentName:"h3"},"Nullable"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"null")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"null")),(0,r.yg)("h4",{id:"type-parameters"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made nullable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L32"},"core/src/lib/Types.ts:32"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optionalt-t--null--undefined"},(0,r.yg)("a",{id:"optional",name:"optional"})," ",(0,r.yg)("strong",{parentName:"h3"},"Optional"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"undefined")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", ",(0,r.yg)("inlineCode",{parentName:"p"},"null"),", and ",(0,r.yg)("inlineCode",{parentName:"p"},"undefined"),"."),(0,r.yg)("h4",{id:"type-parameters-1"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made both nullable and undefinable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L38"},"core/src/lib/Types.ts:38"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-page-puppeteerpage"},(0,r.yg)("a",{id:"page",name:"page"})," ",(0,r.yg)("strong",{parentName:"h3"},"Page"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"PuppeteerPage")),(0,r.yg)("p",null,"This is the puppeteer ",(0,r.yg)("a",{parentName:"p",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nclass used by MemLab. The puppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," class instance provides\nAPIs to interact with the web browser."),(0,r.yg)("p",null,"The puppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," type can be incompatible across different versions.\nYour local npm-installed puppeteer version may be different from\nthe puppeteer used by MemLab. This may cause some type errors, for example:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {Page} from 'puppeteer';\nimport type {RunOptions} from '@memlab/api';\n\nconst runOptions: RunOptions = {\n scenario: {\n // initial page load url: Google Maps\n url: () => {\n return \"https://www.google.com/maps/@37.386427,-122.0428214,11z\";\n },\n // type error here if your local puppeeter version is different\n // from the puppeteer used by MemLab\n action: async function (page: Page) {\n await page.click('button[aria-label=\"Hotels\"]');\n },\n },\n};\n")),(0,r.yg)("p",null,"To avoid the type error in the code example above, MemLab exports the\npuppeteer ",(0,r.yg)("inlineCode",{parentName:"p"},"Page")," type used by MemLab so that your code can import it\nwhen necessary:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {Page} from '@memlab/core' // import Page type from memlab\nimport type {RunOptions} from 'memlab';\n\nconst runOptions: RunOptions = {\n scenario: {\n // initial page load url: Google Maps\n url: () => {\n return \"https://www.google.com/maps/@37.386427,-122.0428214,11z\";\n },\n // no type error here\n action: async function (page: Page) {\n await page.click('button[aria-label=\"Hotels\"]');\n },\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L207"},"core/src/lib/Types.ts:207"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-predicatort-entity-t--boolean"},(0,r.yg)("a",{id:"predicator",name:"predicator"})," ",(0,r.yg)("strong",{parentName:"h3"},"Predicator"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": (",(0,r.yg)("inlineCode",{parentName:"h3"},"entity"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("h4",{id:"type-parameters-2"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"the type of the entity to be checked")))),(0,r.yg)("p",null,"the predicate callback is used to decide if a\nentity of type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),".\nFor more concrete examples on where it is used,\ncheck out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findanyreference"},"findAnyReference"),", ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findanyreferrer"},"findAnyReferrer"),",\nand ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode#findreferrers"},"findReferrers"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"entity"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | the entity to be checked"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | whether the entity passes the predicate check")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L220"},"core/src/lib/Types.ts:220"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-referencefiltercallback-edge-iheapedge-snapshot-iheapsnapshot-isreferenceusedbydefault-boolean--boolean"},(0,r.yg)("a",{id:"referencefiltercallback",name:"referencefiltercallback"})," ",(0,r.yg)("strong",{parentName:"h3"},"ReferenceFilterCallback"),": (",(0,r.yg)("inlineCode",{parentName:"h3"},"edge"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean"),") => ",(0,r.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,r.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be filtered (included) for some\ncalculations (e.g., retainer trace calculation)"),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))," | the reference (edge) that is considered for calcualting the retainer trace"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))," | the final snapshot taken after all browser interactions are done."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default logic for whether a reference should be filtered (included), if this parameter is true, it means MemLab will consider this reference for inclusion"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | the value indicating whether the given reference should be\nfiltered (i.e., included)")),(0,r.yg)("p",null,"Please also be aware that some edges like self-referencing edges,\nJS engine's internal edges, and hidden edges should not be considered\nas part of the retainer trace. These edges could make the retainer trace\nunncessarily complex and cause confusion. ",(0,r.yg)("inlineCode",{parentName:"p"},"isReferenceUsedByDefault")," will\nbe ",(0,r.yg)("inlineCode",{parentName:"p"},"false")," for these types of edges."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// exclude react fiber references\nfunction retainerReferenceFilter(edge, _snapshot, _isReferenceUsedByDefault) {\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n // exclude other references here\n // ...\n return true;\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L624"},"core/src/lib/Types.ts:624"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-runmetainfo-object"},(0,r.yg)("a",{id:"runmetainfo",name:"runmetainfo"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunMetaInfo"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"This data structure holds the information about memlab run.\nYou can retrieve the instance of this type through ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader#getrunmetainfo"},"getRunMetaInfo"),"."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"browserInfo")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},(0,r.yg)("inlineCode",{parentName:"a"},"IBrowserInfo"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"input configuration for the browser and output data from the browser")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"type")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"type of the memlab run")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1247"},"core/src/lib/Types.ts:1247"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-undefinablet-t--undefined"},(0,r.yg)("a",{id:"undefinable",name:"undefinable"})," ",(0,r.yg)("strong",{parentName:"h3"},"Undefinable"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">",": ",(0,r.yg)("inlineCode",{parentName:"h3"},"T")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"h3"},"undefined")),(0,r.yg)("p",null,"Given any type ",(0,r.yg)("inlineCode",{parentName:"p"},"T"),", return the union type ",(0,r.yg)("inlineCode",{parentName:"p"},"T")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"undefined"),"."),(0,r.yg)("h4",{id:"type-parameters-3"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"The type that will be made undefinable.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L44"},"core/src/lib/Types.ts:44"))))),(0,r.yg)("h2",{id:"functions"},"Functions"),(0,r.yg)("h3",{id:"dumpnodeheapsnapshot"},(0,r.yg)("a",{id:"dumpnodeheapsnapshot"}),(0,r.yg)("strong",{parentName:"h3"},"dumpNodeHeapSnapshot"),"()"),(0,r.yg)("p",null,"Take a heap snapshot of the current program state and save it as a\n",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file under a randomly generated folder inside the system's\ntemp folder."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},"Note"),": All ",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," files could also be loaded by Chrome DevTools."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"string")," | the absolute file path to the saved ",(0,r.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/NodeHeap.ts#L84"},"core/src/lib/NodeHeap.ts:84"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"tagobjectto-tag"},(0,r.yg)("a",{id:"tagobject"}),(0,r.yg)("strong",{parentName:"h3"},"tagObject"),"<",(0,r.yg)("inlineCode",{parentName:"h3"},"T"),">","(",(0,r.yg)("inlineCode",{parentName:"h3"},"o"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"tag"),")"),(0,r.yg)("p",null,"Tags a string marker to an object instance, which can later be checked by\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot#hasobjectwithtag"},"hasObjectWithTag"),". This API does not modify the object instance in\nany way (e.g., no additional or hidden properties added to the tagged\nobject)."),(0,r.yg)("h4",{id:"type-parameters-4"},"Type parameters"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"T")),(0,r.yg)("td",{parentName:"tr",align:"left"},"extends ",(0,r.yg)("inlineCode",{parentName:"td"},"object"))))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"o"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | specify the object instance you want to tag, you cannot tag a ",(0,r.yg)("a",{parentName:"li",href:"https://developer.mozilla.org/en-US/docs/Glossary/Primitive"},"primitive"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"tag"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | marker name to tag on the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"T")," | returns the tagged object instance (same reference as\nthe input argument ",(0,r.yg)("inlineCode",{parentName:"li"},"o"),")"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, AnyValue} from '@memlab/core';\nimport {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';\n\ntest('memory test', async () => {\n config.muteConsole = true;\n const o1: AnyValue = {};\n let o2: AnyValue = {};\n\n // tag o1 with marker: \"memlab-mark-1\", does not modify o1 in any way\n tagObject(o1, 'memlab-mark-1');\n // tag o2 with marker: \"memlab-mark-2\", does not modify o2 in any way\n tagObject(o2, 'memlab-mark-2');\n\n o2 = null;\n\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // expect object with marker \"memlab-mark-1\" exists\n expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);\n\n // expect object with marker \"memlab-mark-2\" can be GCed\n expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/NodeHeap.ts#L59"},"core/src/lib/NodeHeap.ts:59"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"takenodeminimalheap"},(0,r.yg)("a",{id:"takenodeminimalheap"}),(0,r.yg)("strong",{parentName:"h3"},"takeNodeMinimalHeap"),"()"),(0,r.yg)("p",null,"Take a heap snapshot of the current program state\nand parse it as ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),". Notice that\nthis API does not calculate some heap analysis meta data\nfor heap analysis. But this also means faster heap parsing."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot")),">"," | heap representation without heap analysis meta data.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples:")))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {takeNodeMinimalHeap} from '@memlab/core';\n\n(async function () {\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n})();\n")),(0,r.yg)("p",null,"If you need to get the heap snapshot with heap analysis meta data, please\nuse ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/NodeHeap.ts#L152"},"core/src/lib/NodeHeap.ts:152"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/27652c34.5e2cc3fe.js b/assets/js/27652c34.d0a6a2c5.js similarity index 95% rename from assets/js/27652c34.5e2cc3fe.js rename to assets/js/27652c34.d0a6a2c5.js index 84e85a84..e31e3fb8 100644 --- a/assets/js/27652c34.5e2cc3fe.js +++ b/assets/js/27652c34.d0a6a2c5.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8417],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var g=r.createContext({}),p=function(e){var a=r.useContext(g),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},s=function(e){var a=p(e.components);return r.createElement(g.Provider,{value:a},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},m=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,i=e.originalType,g=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=p(n),m=t,y=d["".concat(g,".").concat(m)]||d[m]||c[m]||i;return n?r.createElement(y,l(l({ref:a},s),{},{components:n})):r.createElement(y,l({ref:a},s))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var i=n.length,l=new Array(i);l[0]=m;var o={};for(var g in a)hasOwnProperty.call(a,g)&&(o[g]=a[g]);o.originalType=e,o[d]="string"==typeof e?e:t,l[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>g,contentTitle:()=>l,default:()=>c,frontMatter:()=>i,metadata:()=>o,toc:()=>p});var r=n(8168),t=(n(6540),n(5680));const i={id:"core_src.IHeapStringNode",title:"Interface: IHeapStringNode",sidebar_label:"IHeapStringNode",custom_edit_url:null},l=void 0,o={unversionedId:"api/interfaces/core_src.IHeapStringNode",id:"api/interfaces/core_src.IHeapStringNode",title:"Interface: IHeapStringNode",description:"An IHeapStringNode instance represents a JS string in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapStringNode.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapStringNode",title:"Interface: IHeapStringNode",sidebar_label:"IHeapStringNode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},next:{title:"ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter"}},g={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' dominatorNode: Nullable<IHeapNode>',id:"-dominatornode-nullableiheapnode",level:3},{value:' edge_count: number',id:"-edge_count-number",level:3},{value:' hasPathEdge: boolean',id:"-haspathedge-boolean",level:3},{value:' id: number',id:"-id-number",level:3},{value:' isString: boolean',id:"-isstring-boolean",level:3},{value:' is_detached: boolean',id:"-is_detached-boolean",level:3},{value:' location: Nullable<IHeapLocation>',id:"-location-nullableiheaplocation",level:3},{value:' name: string',id:"-name-string",level:3},{value:' nodeIndex: number',id:"-nodeindex-number",level:3},{value:' numOfReferrers: number',id:"-numofreferrers-number",level:3},{value:' pathEdge: null | IHeapEdge',id:"-pathedge-null--iheapedge",level:3},{value:' references: IHeapEdge[]',id:"-references-iheapedge",level:3},{value:' referrers: IHeapEdge[]',id:"-referrers-iheapedge",level:3},{value:' retainedSize: number',id:"-retainedsize-number",level:3},{value:' self_size: number',id:"-self_size-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' stringValue: string',id:"-stringvalue-string",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'findAnyReference(predicate)',id:"findanyreferencepredicate",level:3},{value:'findAnyReferrer(predicate)',id:"findanyreferrerpredicate",level:3},{value:'findAnyReferrerNode(predicate)',id:"findanyreferrernodepredicate",level:3},{value:'findReferrerNodes(predicate)',id:"findreferrernodespredicate",level:3},{value:'findReferrers(predicate)',id:"findreferrerspredicate",level:3},{value:'forEachReference(callback)',id:"foreachreferencecallback",level:3},{value:'forEachReferrer(callback)',id:"foreachreferrercallback",level:3},{value:'getAnyReferrer(edgeName, edgeType?)',id:"getanyreferreredgename-edgetype",level:3},{value:'getAnyReferrerNode(edgeName, edgeType?)',id:"getanyreferrernodeedgename-edgetype",level:3},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'getReference(edgeName, edgeType?)',id:"getreferenceedgename-edgetype",level:3},{value:'getReferenceNode(edgeName, edgeType?)',id:"getreferencenodeedgename-edgetype",level:3},{value:'getReferrerNodes(edgeName, edgeType?)',id:"getreferrernodesedgename-edgetype",level:3},{value:'getReferrers(edgeName, edgeType?)',id:"getreferrersedgename-edgetype",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3},{value:'toStringNode()',id:"tostringnode",level:3}],s={toc:p},d="wrapper";function c(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance represents a JS string in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode, IHeapStringNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n if (node.isString) {\n const stringNode: IheapStringNode = node.toStringNode();\n // get the string value\n stringNode.stringValue;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapStringNode"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-dominatornode-nullableiheapnode"},(0,t.yg)("a",{id:"dominatornode",name:"dominatornode"})," ",(0,t.yg)("strong",{parentName:"h3"},"dominatorNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,t.yg)("p",null,"get the dominator node of this node. If the dominator node gets released\nthere will be no path from GC to this node, and therefore this node can\nalso be released.\nFor more information on what a dominator node is, please check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#dominators"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1904"},"core/src/lib/Types.ts:1904"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-edge_count-number"},(0,t.yg)("a",{id:"edge\\_count",name:"edge\\_count"})," ",(0,t.yg)("strong",{parentName:"h3"},"edge","_","count"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of outgoing JS references (including engine-internal,\nnative, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1858"},"core/src/lib/Types.ts:1858"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-haspathedge-boolean"},(0,t.yg)("a",{id:"haspathedge",name:"haspathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"hasPathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"returns true if the heap node has been set an incoming edge\nwhich leads to the parent node on the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1880"},"core/src/lib/Types.ts:1880"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-id-number"},(0,t.yg)("a",{id:"id",name:"id"})," ",(0,t.yg)("strong",{parentName:"h3"},"id"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"unique id of the heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1785"},"core/src/lib/Types.ts:1785"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-isstring-boolean"},(0,t.yg)("a",{id:"isstring",name:"isstring"})," ",(0,t.yg)("strong",{parentName:"h3"},"isString"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"check if this a string node (normal string node, concatenated string node\nor sliced string node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1916"},"core/src/lib/Types.ts:1916"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_detached-boolean"},(0,t.yg)("a",{id:"is\\_detached",name:"is\\_detached"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","detached"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a DOM element and the DOM element is detached\nfrom the DOM tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a React Fiber node and the Fiber node is unmounted\nfrom the React Fiber tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";\notherwise it will be ",(0,t.yg)("inlineCode",{parentName:"p"},"false"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1840"},"core/src/lib/Types.ts:1840"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-location-nullableiheaplocation"},(0,t.yg)("a",{id:"location",name:"location"})," ",(0,t.yg)("strong",{parentName:"h3"},"location"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapLocation")),">"),(0,t.yg)("p",null,"source location information of this heap object (if it is recorded by\nthe heap snapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1909"},"core/src/lib/Types.ts:1909"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name-string"},(0,t.yg)("a",{id:"name",name:"name"})," ",(0,t.yg)("strong",{parentName:"h3"},"name"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"this is the ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," field associated with the heap object,\nfor JS object instances (type ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),"), ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the constructor's name\nof the object instance. for ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the string value."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1781"},"core/src/lib/Types.ts:1781"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-nodeindex-number"},(0,t.yg)("a",{id:"nodeindex",name:"nodeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"nodeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this heap object inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"node.snapshot.nodes")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1889"},"core/src/lib/Types.ts:1889"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-numofreferrers-number"},(0,t.yg)("a",{id:"numofreferrers",name:"numofreferrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"numOfReferrers"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"Get the number of all incoming references pointing to this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1875"},"core/src/lib/Types.ts:1875"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-pathedge-null--iheapedge"},(0,t.yg)("a",{id:"pathedge",name:"pathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"pathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))),(0,t.yg)("p",null,"The incoming edge which leads to the parent node\non the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1885"},"core/src/lib/Types.ts:1885"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-references-iheapedge"},(0,t.yg)("a",{id:"references",name:"references"})," ",(0,t.yg)("strong",{parentName:"h3"},"references"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all outgoing JS references from this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1865"},"core/src/lib/Types.ts:1865"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-referrers-iheapedge"},(0,t.yg)("a",{id:"referrers",name:"referrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"referrers"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all incoming JS references pointing to this heap\nobject (including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1870"},"core/src/lib/Types.ts:1870"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-retainedsize-number"},(0,t.yg)("a",{id:"retainedsize",name:"retainedsize"})," ",(0,t.yg)("strong",{parentName:"h3"},"retainedSize"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"retained size")," of the heap object (i.e., the total size of memory that\ncould be released if this object is released). For difference between\n",(0,t.yg)("strong",{parentName:"p"},"retained size")," and ",(0,t.yg)("strong",{parentName:"p"},"shallow size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1896"},"core/src/lib/Types.ts:1896"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-self_size-number"},(0,t.yg)("a",{id:"self\\_size",name:"self\\_size"})," ",(0,t.yg)("strong",{parentName:"h3"},"self","_","size"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"shallow size")," of the heap object (i.e., the size of memory that is held\nby the object itself.). For difference between ",(0,t.yg)("strong",{parentName:"p"},"shallow size")," and\n",(0,t.yg)("strong",{parentName:"p"},"retained size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1853"},"core/src/lib/Types.ts:1853"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1832"},"core/src/lib/Types.ts:1832"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-stringvalue-string"},(0,t.yg)("a",{id:"stringvalue",name:"stringvalue"})," ",(0,t.yg)("strong",{parentName:"h3"},"stringValue"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"get the string value of the JS string heap object associated with\nthis ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance in heap"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2226"},"core/src/lib/Types.ts:2226"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"the type of the heap node object. All possible types:\nThis is engine-specific, for example all types in V8:\n",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"array"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"code"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"closure"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"regexp"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"native"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"synthetic"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"concatenated string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"sliced string"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"symbol"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"bigint")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1775"},"core/src/lib/Types.ts:1775"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"findanyreferencepredicate"},(0,t.yg)("a",{id:"findanyreference"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\nin the hosting node (or outgoing edges from the node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first outgoing edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const reference = node.findAnyReference((edge: IHeapEdge) => {\n // find the outgoing reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1997"},"core/src/lib/Types.ts:1997"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrerpredicate"},(0,t.yg)("a",{id:"findanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node) until the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first incoming edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrer((edge: IHeapEdge) => {\n // find the incoming reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2014"},"core/src/lib/Types.ts:2014"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrernodepredicate"},(0,t.yg)("a",{id:"findanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each incoming JavaScript heap object"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the first referring node for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such node is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrerNode((node: IHeapNode) => {\n // find the referring node with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2032"},"core/src/lib/Types.ts:2032"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrernodespredicate"},(0,t.yg)("a",{id:"findreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each referrer nodes"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing all the referrer nodes for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nnode is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrerNodes = node.findReferrerNodes((node: IHeapNode) => {\n // find all the referring nodes with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2067"},"core/src/lib/Types.ts:2067"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrerspredicate"},(0,t.yg)("a",{id:"findreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nedge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrers = node.findReferrers((edge: IHeapEdge) => {\n // find all the incoming references with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2049"},"core/src/lib/Types.ts:2049"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferencecallback"},(0,t.yg)("a",{id:"foreachreference"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference in the\nhosting node (or outgoing edges from the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReference((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.references list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1962"},"core/src/lib/Types.ts:1962"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferrercallback"},(0,t.yg)("a",{id:"foreachreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference pointing\nto the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReferrer((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.referrers list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1980"},"core/src/lib/Types.ts:1980"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferreredgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the incoming edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS reference named \"ref\" pointing to node\nconst reference = node.getAnyReferrer('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2122"},"core/src/lib/Types.ts:2122"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferrernodeedgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds one of the incoming JS\nreferences pointing to the hosting node, and returns the JS heap object\ncontaining the incoming reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node containing the incoming JS reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst n1 = node.getAnyReferrerNode('ref', 'property');\n// this is equivalent to\nconst n2 = node.getAnyReferrer('ref', 'property')?.fromNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2145"},"core/src/lib/Types.ts:2145"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1931"},"core/src/lib/Types.ts:1931"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferenceedgename-edgetype"},(0,t.yg)("a",{id:"getreference"}),(0,t.yg)("strong",{parentName:"h3"},"getReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an outgoing JS\nreference from the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the outgoing edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the internal reference to node's hidden class\nconst reference = node.getReference('map', 'hidden');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2082"},"core/src/lib/Types.ts:2082"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferencenodeedgename-edgetype"},(0,t.yg)("a",{id:"getreferencenode"}),(0,t.yg)("strong",{parentName:"h3"},"getReferenceNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds the outgoing JS\nreference from the hosting node, and returns the JS heap object pointed to\nby the outgoing JS reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node pointed to by the outgoing reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the node's hidden class\nconst hiddenClassNode = node.getReferenceNode('map', 'hidden');\n// this is equivalent to\nconst hiddenClassNode2 = node.getReference('map', 'hidden')?.toNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2104"},"core/src/lib/Types.ts:2104"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrernodesedgename-edgetype"},(0,t.yg)("a",{id:"getreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all of the incoming JS\nreferences pointing to the hosting node, and returns an array containing\nthe hosting node for each of the incoming JS references."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing the hosting nodes, with each node corresponds\nto each incoming JS reference that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst nodes1 = node.getReferrerNodes('ref', 'property');\n// this is equivalent to\nconst nodes2 = node.getReferrers('ref', 'property')\n .map(edge => edge.fromNode);\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2185"},"core/src/lib/Types.ts:2185"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrersedgename-edgetype"},(0,t.yg)("a",{id:"getreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all the incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges that\nmeet the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of of the JS reference named \"ref\" pointing to node\nconst referrers = node.getReferrers('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2164"},"core/src/lib/Types.ts:2164"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1944"},"core/src/lib/Types.ts:1944"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tostringnode"},(0,t.yg)("a",{id:"tostringnode"}),(0,t.yg)("strong",{parentName:"h3"},"toStringNode"),"()"),(0,t.yg)("p",null,"convert to an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object if this node is a string node.\nThe ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object supports querying the string content\ninside the string node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode")),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1922"},"core/src/lib/Types.ts:1922"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8417],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var g=r.createContext({}),p=function(e){var a=r.useContext(g),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},s=function(e){var a=p(e.components);return r.createElement(g.Provider,{value:a},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},m=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,i=e.originalType,g=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=p(n),m=t,y=d["".concat(g,".").concat(m)]||d[m]||c[m]||i;return n?r.createElement(y,l(l({ref:a},s),{},{components:n})):r.createElement(y,l({ref:a},s))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var i=n.length,l=new Array(i);l[0]=m;var o={};for(var g in a)hasOwnProperty.call(a,g)&&(o[g]=a[g]);o.originalType=e,o[d]="string"==typeof e?e:t,l[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>g,contentTitle:()=>l,default:()=>c,frontMatter:()=>i,metadata:()=>o,toc:()=>p});var r=n(8168),t=(n(6540),n(5680));const i={id:"core_src.IHeapStringNode",title:"Interface: IHeapStringNode",sidebar_label:"IHeapStringNode",custom_edit_url:null},l=void 0,o={unversionedId:"api/interfaces/core_src.IHeapStringNode",id:"api/interfaces/core_src.IHeapStringNode",title:"Interface: IHeapStringNode",description:"An IHeapStringNode instance represents a JS string in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapStringNode.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapStringNode",title:"Interface: IHeapStringNode",sidebar_label:"IHeapStringNode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},next:{title:"ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter"}},g={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' dominatorNode: Nullable<IHeapNode>',id:"-dominatornode-nullableiheapnode",level:3},{value:' edge_count: number',id:"-edge_count-number",level:3},{value:' hasPathEdge: boolean',id:"-haspathedge-boolean",level:3},{value:' id: number',id:"-id-number",level:3},{value:' isString: boolean',id:"-isstring-boolean",level:3},{value:' is_detached: boolean',id:"-is_detached-boolean",level:3},{value:' location: Nullable<IHeapLocation>',id:"-location-nullableiheaplocation",level:3},{value:' name: string',id:"-name-string",level:3},{value:' nodeIndex: number',id:"-nodeindex-number",level:3},{value:' numOfReferrers: number',id:"-numofreferrers-number",level:3},{value:' pathEdge: null | IHeapEdge',id:"-pathedge-null--iheapedge",level:3},{value:' references: IHeapEdge[]',id:"-references-iheapedge",level:3},{value:' referrers: IHeapEdge[]',id:"-referrers-iheapedge",level:3},{value:' retainedSize: number',id:"-retainedsize-number",level:3},{value:' self_size: number',id:"-self_size-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' stringValue: string',id:"-stringvalue-string",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'findAnyReference(predicate)',id:"findanyreferencepredicate",level:3},{value:'findAnyReferrer(predicate)',id:"findanyreferrerpredicate",level:3},{value:'findAnyReferrerNode(predicate)',id:"findanyreferrernodepredicate",level:3},{value:'findReferrerNodes(predicate)',id:"findreferrernodespredicate",level:3},{value:'findReferrers(predicate)',id:"findreferrerspredicate",level:3},{value:'forEachReference(callback)',id:"foreachreferencecallback",level:3},{value:'forEachReferrer(callback)',id:"foreachreferrercallback",level:3},{value:'getAnyReferrer(edgeName, edgeType?)',id:"getanyreferreredgename-edgetype",level:3},{value:'getAnyReferrerNode(edgeName, edgeType?)',id:"getanyreferrernodeedgename-edgetype",level:3},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'getReference(edgeName, edgeType?)',id:"getreferenceedgename-edgetype",level:3},{value:'getReferenceNode(edgeName, edgeType?)',id:"getreferencenodeedgename-edgetype",level:3},{value:'getReferrerNodes(edgeName, edgeType?)',id:"getreferrernodesedgename-edgetype",level:3},{value:'getReferrers(edgeName, edgeType?)',id:"getreferrersedgename-edgetype",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3},{value:'toStringNode()',id:"tostringnode",level:3}],s={toc:p},d="wrapper";function c(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance represents a JS string in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode, IHeapStringNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n if (node.isString) {\n const stringNode: IheapStringNode = node.toStringNode();\n // get the string value\n stringNode.stringValue;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapStringNode"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-dominatornode-nullableiheapnode"},(0,t.yg)("a",{id:"dominatornode",name:"dominatornode"})," ",(0,t.yg)("strong",{parentName:"h3"},"dominatorNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,t.yg)("p",null,"get the dominator node of this node. If the dominator node gets released\nthere will be no path from GC to this node, and therefore this node can\nalso be released.\nFor more information on what a dominator node is, please check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#dominators"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1904"},"core/src/lib/Types.ts:1904"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-edge_count-number"},(0,t.yg)("a",{id:"edge\\_count",name:"edge\\_count"})," ",(0,t.yg)("strong",{parentName:"h3"},"edge","_","count"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of outgoing JS references (including engine-internal,\nnative, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1858"},"core/src/lib/Types.ts:1858"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-haspathedge-boolean"},(0,t.yg)("a",{id:"haspathedge",name:"haspathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"hasPathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"returns true if the heap node has been set an incoming edge\nwhich leads to the parent node on the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1880"},"core/src/lib/Types.ts:1880"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-id-number"},(0,t.yg)("a",{id:"id",name:"id"})," ",(0,t.yg)("strong",{parentName:"h3"},"id"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"unique id of the heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1785"},"core/src/lib/Types.ts:1785"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-isstring-boolean"},(0,t.yg)("a",{id:"isstring",name:"isstring"})," ",(0,t.yg)("strong",{parentName:"h3"},"isString"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"check if this a string node (normal string node, concatenated string node\nor sliced string node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1916"},"core/src/lib/Types.ts:1916"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_detached-boolean"},(0,t.yg)("a",{id:"is\\_detached",name:"is\\_detached"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","detached"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a DOM element and the DOM element is detached\nfrom the DOM tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},"If the heap object is a React Fiber node and the Fiber node is unmounted\nfrom the React Fiber tree, ",(0,t.yg)("inlineCode",{parentName:"p"},"is_detached")," will be ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),";\notherwise it will be ",(0,t.yg)("inlineCode",{parentName:"p"},"false"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1840"},"core/src/lib/Types.ts:1840"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-location-nullableiheaplocation"},(0,t.yg)("a",{id:"location",name:"location"})," ",(0,t.yg)("strong",{parentName:"h3"},"location"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapLocation"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapLocation")),">"),(0,t.yg)("p",null,"source location information of this heap object (if it is recorded by\nthe heap snapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1909"},"core/src/lib/Types.ts:1909"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name-string"},(0,t.yg)("a",{id:"name",name:"name"})," ",(0,t.yg)("strong",{parentName:"h3"},"name"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"this is the ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," field associated with the heap object,\nfor JS object instances (type ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),"), ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the constructor's name\nof the object instance. for ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"name")," is the string value."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1781"},"core/src/lib/Types.ts:1781"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-nodeindex-number"},(0,t.yg)("a",{id:"nodeindex",name:"nodeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"nodeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this heap object inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"node.snapshot.nodes")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1889"},"core/src/lib/Types.ts:1889"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-numofreferrers-number"},(0,t.yg)("a",{id:"numofreferrers",name:"numofreferrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"numOfReferrers"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"Get the number of all incoming references pointing to this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1875"},"core/src/lib/Types.ts:1875"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-pathedge-null--iheapedge"},(0,t.yg)("a",{id:"pathedge",name:"pathedge"})," ",(0,t.yg)("strong",{parentName:"h3"},"pathEdge"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"null")," ","|"," ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge"))),(0,t.yg)("p",null,"The incoming edge which leads to the parent node\non the shortest path to GC root."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1885"},"core/src/lib/Types.ts:1885"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-references-iheapedge"},(0,t.yg)("a",{id:"references",name:"references"})," ",(0,t.yg)("strong",{parentName:"h3"},"references"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all outgoing JS references from this heap object\n(including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1865"},"core/src/lib/Types.ts:1865"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-referrers-iheapedge"},(0,t.yg)("a",{id:"referrers",name:"referrers"})," ",(0,t.yg)("strong",{parentName:"h3"},"referrers"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[]"),(0,t.yg)("p",null,"Get a JS array containing all incoming JS references pointing to this heap\nobject (including engine-internal, native, and JS references)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1870"},"core/src/lib/Types.ts:1870"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-retainedsize-number"},(0,t.yg)("a",{id:"retainedsize",name:"retainedsize"})," ",(0,t.yg)("strong",{parentName:"h3"},"retainedSize"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"retained size")," of the heap object (i.e., the total size of memory that\ncould be released if this object is released). For difference between\n",(0,t.yg)("strong",{parentName:"p"},"retained size")," and ",(0,t.yg)("strong",{parentName:"p"},"shallow size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1896"},"core/src/lib/Types.ts:1896"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-self_size-number"},(0,t.yg)("a",{id:"self\\_size",name:"self\\_size"})," ",(0,t.yg)("strong",{parentName:"h3"},"self","_","size"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The ",(0,t.yg)("em",{parentName:"p"},"shallow size")," of the heap object (i.e., the size of memory that is held\nby the object itself.). For difference between ",(0,t.yg)("strong",{parentName:"p"},"shallow size")," and\n",(0,t.yg)("strong",{parentName:"p"},"retained size"),", check out\n",(0,t.yg)("a",{parentName:"p",href:"https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes"},"this doc"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1853"},"core/src/lib/Types.ts:1853"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this heap object"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1832"},"core/src/lib/Types.ts:1832"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-stringvalue-string"},(0,t.yg)("a",{id:"stringvalue",name:"stringvalue"})," ",(0,t.yg)("strong",{parentName:"h3"},"stringValue"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"get the string value of the JS string heap object associated with\nthis ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapStringNode")," instance in heap"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2226"},"core/src/lib/Types.ts:2226"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"the type of the heap node object. All possible types:\nThis is engine-specific, for example all types in V8:\n",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"array"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"object"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"code"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"closure"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"regexp"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"native"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"synthetic"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"concatenated string"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"sliced string"),",\n",(0,t.yg)("inlineCode",{parentName:"p"},"symbol"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"bigint")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1775"},"core/src/lib/Types.ts:1775"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"findanyreferencepredicate"},(0,t.yg)("a",{id:"findanyreference"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\nin the hosting node (or outgoing edges from the node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first outgoing edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const reference = node.findAnyReference((edge: IHeapEdge) => {\n // find the outgoing reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1997"},"core/src/lib/Types.ts:1997"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrerpredicate"},(0,t.yg)("a",{id:"findanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node) until the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the first incoming edge for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such edge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrer((edge: IHeapEdge) => {\n // find the incoming reference with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2014"},"core/src/lib/Types.ts:2014"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findanyreferrernodepredicate"},(0,t.yg)("a",{id:"findanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"findAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node) until the predicate\nreturns ",(0,t.yg)("inlineCode",{parentName:"p"},"true")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each incoming JavaScript heap object"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the first referring node for which the predicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),",\notherwise returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null")," if no such node is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrer = node.findAnyReferrerNode((node: IHeapNode) => {\n // find the referring node with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2032"},"core/src/lib/Types.ts:2032"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrernodespredicate"},(0,t.yg)("a",{id:"findreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript heap\nobject (heap graph node) pointing to the hosting node\n(or nodes having edges to the hosting node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the callback for each referrer nodes"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing all the referrer nodes for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nnode is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrerNodes = node.findReferrerNodes((node: IHeapNode) => {\n // find all the referring nodes with name \"Parent\"\n return node.name === 'Parent';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2067"},"core/src/lib/Types.ts:2067"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"findreferrerspredicate"},(0,t.yg)("a",{id:"findreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"findReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"predicate"),")"),(0,t.yg)("p",null,"executes a provided predicate callback once for each JavaScript reference\npointing to the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"predicate"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#predicator"},(0,t.yg)("inlineCode",{parentName:"a"},"Predicator")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges for which the\npredicate returns ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", otherwise returns an empty array if no such\nedge is found.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const referrers = node.findReferrers((edge: IHeapEdge) => {\n // find all the incoming references with name \"ref\"\n return edge.name_or_index === 'ref';\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2049"},"core/src/lib/Types.ts:2049"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferencecallback"},(0,t.yg)("a",{id:"foreachreference"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference in the\nhosting node (or outgoing edges from the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReference((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.references list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1962"},"core/src/lib/Types.ts:1962"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"foreachreferrercallback"},(0,t.yg)("a",{id:"foreachreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"forEachReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"executes a provided callback once for each JavaScript reference pointing\nto the hosting node (or incoming edges to the node)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#edgeiterationcallback"},(0,t.yg)("inlineCode",{parentName:"a"},"EdgeIterationCallback"))," | the callback for each incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"void")," | this API returns void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"node.forEachReferrer((edge: IHeapEdge) => {\n // process edge ...\n\n // if no need to iterate over remaining edges after\n // the current edge in the node.referrers list\n return {stop: true};\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1980"},"core/src/lib/Types.ts:1980"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferreredgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrer"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrer"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the incoming edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS reference named \"ref\" pointing to node\nconst reference = node.getAnyReferrer('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2122"},"core/src/lib/Types.ts:2122"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getanyreferrernodeedgename-edgetype"},(0,t.yg)("a",{id:"getanyreferrernode"}),(0,t.yg)("strong",{parentName:"h3"},"getAnyReferrerNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds one of the incoming JS\nreferences pointing to the hosting node, and returns the JS heap object\ncontaining the incoming reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node containing the incoming JS reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find one of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst n1 = node.getAnyReferrerNode('ref', 'property');\n// this is equivalent to\nconst n2 = node.getAnyReferrer('ref', 'property')?.fromNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2145"},"core/src/lib/Types.ts:2145"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1931"},"core/src/lib/Types.ts:1931"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferenceedgename-edgetype"},(0,t.yg)("a",{id:"getreference"}),(0,t.yg)("strong",{parentName:"h3"},"getReference"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds an outgoing JS\nreference from the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | the outgoing edge that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the internal reference to node's hidden class\nconst reference = node.getReference('map', 'hidden');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2082"},"core/src/lib/Types.ts:2082"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferencenodeedgename-edgetype"},(0,t.yg)("a",{id:"getreferencenode"}),(0,t.yg)("strong",{parentName:"h3"},"getReferenceNode"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds the outgoing JS\nreference from the hosting node, and returns the JS heap object pointed to\nby the outgoing JS reference."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the outgoing JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the outgoing JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the node pointed to by the outgoing reference that meets\nthe specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find the node's hidden class\nconst hiddenClassNode = node.getReferenceNode('map', 'hidden');\n// this is equivalent to\nconst hiddenClassNode2 = node.getReference('map', 'hidden')?.toNode;\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2104"},"core/src/lib/Types.ts:2104"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrernodesedgename-edgetype"},(0,t.yg)("a",{id:"getreferrernodes"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrerNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all of the incoming JS\nreferences pointing to the hosting node, and returns an array containing\nthe hosting node for each of the incoming JS references."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),"[] | an array containing the hosting nodes, with each node corresponds\nto each incoming JS reference that meets the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of the JS heap object with a JS reference\n// named \"ref\" pointing to node\nconst nodes1 = node.getReferrerNodes('ref', 'property');\n// this is equivalent to\nconst nodes2 = node.getReferrers('ref', 'property')\n .map(edge => edge.fromNode);\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2185"},"core/src/lib/Types.ts:2185"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getreferrersedgename-edgetype"},(0,t.yg)("a",{id:"getreferrers"}),(0,t.yg)("strong",{parentName:"h3"},"getReferrers"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeName"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"edgeType?"),")"),(0,t.yg)("p",null,"Given a JS reference's name and type, this API finds all the incoming JS\nreference pointing to the hosting node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeName"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the name of the incoming JavaScript reference"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edgeType?"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | optional parameter specifying the type of the incoming JavaScript reference"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),"[] | an array containing all the incoming edges that\nmeet the specification")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"// find all of of the JS reference named \"ref\" pointing to node\nconst referrers = node.getReferrers('ref', 'property');\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2164"},"core/src/lib/Types.ts:2164"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1944"},"core/src/lib/Types.ts:1944"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tostringnode"},(0,t.yg)("a",{id:"tostringnode"}),(0,t.yg)("strong",{parentName:"h3"},"toStringNode"),"()"),(0,t.yg)("p",null,"convert to an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object if this node is a string node.\nThe ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},"IHeapStringNode")," object supports querying the string content\ninside the string node."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapStringNode")),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1922"},"core/src/lib/Types.ts:1922"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/2d8affd8.faed0bb1.js b/assets/js/2d8affd8.b192b553.js similarity index 96% rename from assets/js/2d8affd8.faed0bb1.js rename to assets/js/2d8affd8.b192b553.js index 9a5dd766..09919d31 100644 --- a/assets/js/2d8affd8.faed0bb1.js +++ b/assets/js/2d8affd8.b192b553.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8032],{5680:(e,t,n)=>{n.d(t,{xA:()=>p,yg:()=>g});var a=n(6540);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=a.createContext({}),u=function(e){var t=a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=u(e.components);return a.createElement(s.Provider,{value:t},e.children)},m="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},d=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),m=u(n),d=r,g=m["".concat(s,".").concat(d)]||m[d]||c[d]||o;return n?a.createElement(g,l(l({ref:t},p),{},{components:n})):a.createElement(g,l({ref:t},p))}));function g(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=d;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i[m]="string"==typeof e?e:r,l[1]=i;for(var u=2;u{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>o,metadata:()=>i,toc:()=>u});var a=n(8168),r=(n(6540),n(5680));const o={id:"api_src.ConsoleMode",title:"Enumeration: ConsoleMode",sidebar_label:"ConsoleMode",custom_edit_url:null},l=void 0,i={unversionedId:"api/enums/api_src.ConsoleMode",id:"api/enums/api_src.ConsoleMode",title:"Enumeration: ConsoleMode",description:"enum of all console mode options",source:"@site/docs/api/enums/api_src.ConsoleMode.md",sourceDirName:"api/enums",slug:"/api/enums/api_src.ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.ConsoleMode",title:"Enumeration: ConsoleMode",sidebar_label:"ConsoleMode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"heap-analysis/src",permalink:"/memlab/docs/api/modules/heap_analysis_src"},next:{title:"BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"}},s={},u=[{value:"Enumeration Members",id:"enumeration-members",level:2},{value:' CONTINUOUS_TEST',id:"-continuous_test",level:3},{value:' DEFAULT',id:"-default",level:3},{value:' SILENT',id:"-silent",level:3},{value:' VERBOSE',id:"-verbose",level:3}],p={toc:u},m="wrapper";function c(e){let{components:t,...n}=e;return(0,r.yg)(m,(0,a.A)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"enum of all console mode options"),(0,r.yg)("h2",{id:"enumeration-members"},"Enumeration Members"),(0,r.yg)("h3",{id:"-continuous_test"},(0,r.yg)("a",{id:"continuous\\_test",name:"continuous\\_test"})," ",(0,r.yg)("strong",{parentName:"h3"},"CONTINUOUS","_","TEST")),(0,r.yg)("p",null,"continuous test mode, no terminal output overwrite or animation,\nequivalent to using ",(0,r.yg)("inlineCode",{parentName:"p"},"--sc")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/state/ConsoleModeManager.ts#L26"},"api/src/state/ConsoleModeManager.ts:26"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-default"},(0,r.yg)("a",{id:"default",name:"default"})," ",(0,r.yg)("strong",{parentName:"h3"},"DEFAULT")),(0,r.yg)("p",null,"the default mode, there could be terminal output overwrite and animation,"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/state/ConsoleModeManager.ts#L30"},"api/src/state/ConsoleModeManager.ts:30"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-silent"},(0,r.yg)("a",{id:"silent",name:"silent"})," ",(0,r.yg)("strong",{parentName:"h3"},"SILENT")),(0,r.yg)("p",null,"mute all terminal output, equivalent to using ",(0,r.yg)("inlineCode",{parentName:"p"},"--silent")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/state/ConsoleModeManager.ts#L21"},"api/src/state/ConsoleModeManager.ts:21"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-verbose"},(0,r.yg)("a",{id:"verbose",name:"verbose"})," ",(0,r.yg)("strong",{parentName:"h3"},"VERBOSE")),(0,r.yg)("p",null,"verbose mode, there could be terminal output overwrite and animation"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/state/ConsoleModeManager.ts#L34"},"api/src/state/ConsoleModeManager.ts:34"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8032],{5680:(e,t,n)=>{n.d(t,{xA:()=>p,yg:()=>g});var a=n(6540);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=a.createContext({}),u=function(e){var t=a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=u(e.components);return a.createElement(s.Provider,{value:t},e.children)},m="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},d=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),m=u(n),d=r,g=m["".concat(s,".").concat(d)]||m[d]||c[d]||o;return n?a.createElement(g,l(l({ref:t},p),{},{components:n})):a.createElement(g,l({ref:t},p))}));function g(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=d;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i[m]="string"==typeof e?e:r,l[1]=i;for(var u=2;u{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>o,metadata:()=>i,toc:()=>u});var a=n(8168),r=(n(6540),n(5680));const o={id:"api_src.ConsoleMode",title:"Enumeration: ConsoleMode",sidebar_label:"ConsoleMode",custom_edit_url:null},l=void 0,i={unversionedId:"api/enums/api_src.ConsoleMode",id:"api/enums/api_src.ConsoleMode",title:"Enumeration: ConsoleMode",description:"enum of all console mode options",source:"@site/docs/api/enums/api_src.ConsoleMode.md",sourceDirName:"api/enums",slug:"/api/enums/api_src.ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.ConsoleMode",title:"Enumeration: ConsoleMode",sidebar_label:"ConsoleMode",custom_edit_url:null},sidebar:"sidebar",previous:{title:"heap-analysis/src",permalink:"/memlab/docs/api/modules/heap_analysis_src"},next:{title:"BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"}},s={},u=[{value:"Enumeration Members",id:"enumeration-members",level:2},{value:' CONTINUOUS_TEST',id:"-continuous_test",level:3},{value:' DEFAULT',id:"-default",level:3},{value:' SILENT',id:"-silent",level:3},{value:' VERBOSE',id:"-verbose",level:3}],p={toc:u},m="wrapper";function c(e){let{components:t,...n}=e;return(0,r.yg)(m,(0,a.A)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"enum of all console mode options"),(0,r.yg)("h2",{id:"enumeration-members"},"Enumeration Members"),(0,r.yg)("h3",{id:"-continuous_test"},(0,r.yg)("a",{id:"continuous\\_test",name:"continuous\\_test"})," ",(0,r.yg)("strong",{parentName:"h3"},"CONTINUOUS","_","TEST")),(0,r.yg)("p",null,"continuous test mode, no terminal output overwrite or animation,\nequivalent to using ",(0,r.yg)("inlineCode",{parentName:"p"},"--sc")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/state/ConsoleModeManager.ts#L26"},"api/src/state/ConsoleModeManager.ts:26"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-default"},(0,r.yg)("a",{id:"default",name:"default"})," ",(0,r.yg)("strong",{parentName:"h3"},"DEFAULT")),(0,r.yg)("p",null,"the default mode, there could be terminal output overwrite and animation,"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/state/ConsoleModeManager.ts#L30"},"api/src/state/ConsoleModeManager.ts:30"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-silent"},(0,r.yg)("a",{id:"silent",name:"silent"})," ",(0,r.yg)("strong",{parentName:"h3"},"SILENT")),(0,r.yg)("p",null,"mute all terminal output, equivalent to using ",(0,r.yg)("inlineCode",{parentName:"p"},"--silent")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/state/ConsoleModeManager.ts#L21"},"api/src/state/ConsoleModeManager.ts:21"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-verbose"},(0,r.yg)("a",{id:"verbose",name:"verbose"})," ",(0,r.yg)("strong",{parentName:"h3"},"VERBOSE")),(0,r.yg)("p",null,"verbose mode, there could be terminal output overwrite and animation"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/state/ConsoleModeManager.ts#L34"},"api/src/state/ConsoleModeManager.ts:34"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/2ecac66d.f5f0f42b.js b/assets/js/2ecac66d.327215f5.js similarity index 94% rename from assets/js/2ecac66d.f5f0f42b.js rename to assets/js/2ecac66d.327215f5.js index 98e5de0f..7fdf9911 100644 --- a/assets/js/2ecac66d.f5f0f42b.js +++ b/assets/js/2ecac66d.327215f5.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1797],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>u});var t=n(6540);function l(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function s(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(l[n]=e[n]);return l}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},g=t.forwardRef((function(e,a){var n=e.components,l=e.mdxType,s=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),g=l,u=c["".concat(o,".").concat(g)]||c[g]||m[g]||s;return n?t.createElement(u,i(i({ref:a},y),{},{components:n})):t.createElement(u,i({ref:a},y))}));function u(e,a){var n=arguments,l=a&&a.mdxType;if("string"==typeof e||l){var s=n.length,i=new Array(s);i[0]=g;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:l,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>s,metadata:()=>r,toc:()=>p});var t=n(8168),l=(n(6540),n(5680));const s={id:"heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",sidebar_label:"DetachedDOMElementAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.DetachedDOMElementAnalysis",id:"api/classes/heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",sidebar_label:"DetachedDOMElementAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},next:{title:"GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new DetachedDOMElementAnalysis()',id:"new-detacheddomelementanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getDetachedElements()',id:"getdetachedelements",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,l.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,l.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,l.yg)("p",{parentName:"li"},"\u21b3 ",(0,l.yg)("strong",{parentName:"p"},(0,l.yg)("inlineCode",{parentName:"strong"},"DetachedDOMElementAnalysis"))))),(0,l.yg)("h2",{id:"constructors"},"Constructors"),(0,l.yg)("h3",{id:"new-detacheddomelementanalysis"},(0,l.yg)("a",{id:"new detacheddomelementanalysis"}),(0,l.yg)("strong",{parentName:"h3"},"new DetachedDOMElementAnalysis"),"()"),(0,l.yg)("h2",{id:"methods"},"Methods"),(0,l.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,l.yg)("a",{id:"analyzesnapshotfromfile"}),(0,l.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,l.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,l.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,l.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Parameters"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,l.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,l.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,l.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Example"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,l.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getcommandname"},(0,l.yg)("a",{id:"getcommandname"}),(0,l.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,l.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,l.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,l.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Examples"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts#L21"},"heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts:21"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getdetachedelements"},(0,l.yg)("a",{id:"getdetachedelements"}),(0,l.yg)("strong",{parentName:"h3"},"getDetachedElements"),"()"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"IHeapNode"),"[]"),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts#L48"},"heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts:48"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1797],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>d});var t=n(6540);function l(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function s(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(l[n]=e[n]);return l}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},g=t.forwardRef((function(e,a){var n=e.components,l=e.mdxType,s=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),g=l,d=c["".concat(o,".").concat(g)]||c[g]||m[g]||s;return n?t.createElement(d,i(i({ref:a},y),{},{components:n})):t.createElement(d,i({ref:a},y))}));function d(e,a){var n=arguments,l=a&&a.mdxType;if("string"==typeof e||l){var s=n.length,i=new Array(s);i[0]=g;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:l,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>s,metadata:()=>r,toc:()=>p});var t=n(8168),l=(n(6540),n(5680));const s={id:"heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",sidebar_label:"DetachedDOMElementAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.DetachedDOMElementAnalysis",id:"api/classes/heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.DetachedDOMElementAnalysis",title:"Class: DetachedDOMElementAnalysis",sidebar_label:"DetachedDOMElementAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},next:{title:"GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new DetachedDOMElementAnalysis()',id:"new-detacheddomelementanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getDetachedElements()',id:"getdetachedelements",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,l.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,l.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,l.yg)("p",{parentName:"li"},"\u21b3 ",(0,l.yg)("strong",{parentName:"p"},(0,l.yg)("inlineCode",{parentName:"strong"},"DetachedDOMElementAnalysis"))))),(0,l.yg)("h2",{id:"constructors"},"Constructors"),(0,l.yg)("h3",{id:"new-detacheddomelementanalysis"},(0,l.yg)("a",{id:"new detacheddomelementanalysis"}),(0,l.yg)("strong",{parentName:"h3"},"new DetachedDOMElementAnalysis"),"()"),(0,l.yg)("h2",{id:"methods"},"Methods"),(0,l.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,l.yg)("a",{id:"analyzesnapshotfromfile"}),(0,l.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,l.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,l.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,l.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Parameters"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,l.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,l.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,l.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Example"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,l.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getcommandname"},(0,l.yg)("a",{id:"getcommandname"}),(0,l.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,l.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,l.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,l.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Examples"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts#L21"},"heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts:21"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getdetachedelements"},(0,l.yg)("a",{id:"getdetachedelements"}),(0,l.yg)("strong",{parentName:"h3"},"getDetachedElements"),"()"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"IHeapNode"),"[]"),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts#L48"},"heap-analysis/src/plugins/DetachedDOMElementAnalysis.ts:48"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/3531de3b.3c9fc781.js b/assets/js/3531de3b.8689b73f.js similarity index 88% rename from assets/js/3531de3b.3c9fc781.js rename to assets/js/3531de3b.8689b73f.js index 6252d38e..57c7d35c 100644 --- a/assets/js/3531de3b.3c9fc781.js +++ b/assets/js/3531de3b.8689b73f.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9477],{5680:(e,r,n)=>{n.d(r,{xA:()=>p,yg:()=>f});var t=n(6540);function o(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function a(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function s(e){for(var r=1;r=0||(o[n]=e[n]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=t.createContext({}),c=function(e){var r=t.useContext(l),n=r;return e&&(n="function"==typeof e?e(r):s(s({},r),e)),n},p=function(e){var r=c(e.components);return t.createElement(l.Provider,{value:r},e.children)},u="mdxType",g={inlineCode:"code",wrapper:function(e){var r=e.children;return t.createElement(t.Fragment,{},r)}},m=t.forwardRef((function(e,r){var n=e.components,o=e.mdxType,a=e.originalType,l=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),u=c(n),m=o,f=u["".concat(l,".").concat(m)]||u[m]||g[m]||a;return n?t.createElement(f,s(s({ref:r},p),{},{components:n})):t.createElement(f,s({ref:r},p))}));function f(e,r){var n=arguments,o=r&&r.mdxType;if("string"==typeof e||o){var a=n.length,s=new Array(a);s[0]=m;var i={};for(var l in r)hasOwnProperty.call(r,l)&&(i[l]=r[l]);i.originalType=e,i[u]="string"==typeof e?e:o,s[1]=i;for(var c=2;c{n.r(r),n.d(r,{assets:()=>l,contentTitle:()=>s,default:()=>g,frontMatter:()=>a,metadata:()=>i,toc:()=>c});var t=n(8168),o=(n(6540),n(5680));const a={id:"core_src.IBrowserInfo",title:"Interface: IBrowserInfo",sidebar_label:"IBrowserInfo",custom_edit_url:null},s=void 0,i={unversionedId:"api/interfaces/core_src.IBrowserInfo",id:"api/interfaces/core_src.IBrowserInfo",title:"Interface: IBrowserInfo",description:"This data structure contains the input configuration for the browser and",source:"@site/docs/api/interfaces/core_src.IBrowserInfo.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IBrowserInfo",title:"Interface: IBrowserInfo",sidebar_label:"IBrowserInfo",custom_edit_url:null},sidebar:"sidebar",previous:{title:"StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},next:{title:"IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge"}},l={},c=[{value:"Properties",id:"properties",level:2},{value:' _browserVersion: string',id:"-_browserversion-string",level:3},{value:' _consoleMessages: string[]',id:"-_consolemessages-string",level:3},{value:' _puppeteerConfig: LaunchOptions',id:"-_puppeteerconfig-launchoptions",level:3}],p={toc:c},u="wrapper";function g(e){let{components:r,...n}=e;return(0,o.yg)(u,(0,t.A)({},p,n,{components:r,mdxType:"MDXLayout"}),(0,o.yg)("p",null,"This data structure contains the input configuration for the browser and\noutput data from the browser. You can retrieve the instance of this type\nthrough ",(0,o.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#runmetainfo"},"RunMetaInfo"),"."),(0,o.yg)("h2",{id:"properties"},"Properties"),(0,o.yg)("h3",{id:"-_browserversion-string"},(0,o.yg)("a",{id:"\\_browserversion",name:"\\_browserversion"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","browserVersion"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"string")),(0,o.yg)("p",null,"browser version"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1232"},"core/src/lib/Types.ts:1232"))))),(0,o.yg)("hr",null),(0,o.yg)("h3",{id:"-_consolemessages-string"},(0,o.yg)("a",{id:"\\_consolemessages",name:"\\_consolemessages"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","consoleMessages"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"string"),"[]"),(0,o.yg)("p",null,"all web console output"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1240"},"core/src/lib/Types.ts:1240"))))),(0,o.yg)("hr",null),(0,o.yg)("h3",{id:"-_puppeteerconfig-launchoptions"},(0,o.yg)("a",{id:"\\_puppeteerconfig",name:"\\_puppeteerconfig"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","puppeteerConfig"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"LaunchOptions")),(0,o.yg)("p",null,"configuration for puppeteer"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1236"},"core/src/lib/Types.ts:1236"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9477],{5680:(e,r,n)=>{n.d(r,{xA:()=>p,yg:()=>m});var t=n(6540);function o(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function a(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function s(e){for(var r=1;r=0||(o[n]=e[n]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=t.createContext({}),c=function(e){var r=t.useContext(l),n=r;return e&&(n="function"==typeof e?e(r):s(s({},r),e)),n},p=function(e){var r=c(e.components);return t.createElement(l.Provider,{value:r},e.children)},u="mdxType",g={inlineCode:"code",wrapper:function(e){var r=e.children;return t.createElement(t.Fragment,{},r)}},f=t.forwardRef((function(e,r){var n=e.components,o=e.mdxType,a=e.originalType,l=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),u=c(n),f=o,m=u["".concat(l,".").concat(f)]||u[f]||g[f]||a;return n?t.createElement(m,s(s({ref:r},p),{},{components:n})):t.createElement(m,s({ref:r},p))}));function m(e,r){var n=arguments,o=r&&r.mdxType;if("string"==typeof e||o){var a=n.length,s=new Array(a);s[0]=f;var i={};for(var l in r)hasOwnProperty.call(r,l)&&(i[l]=r[l]);i.originalType=e,i[u]="string"==typeof e?e:o,s[1]=i;for(var c=2;c{n.r(r),n.d(r,{assets:()=>l,contentTitle:()=>s,default:()=>g,frontMatter:()=>a,metadata:()=>i,toc:()=>c});var t=n(8168),o=(n(6540),n(5680));const a={id:"core_src.IBrowserInfo",title:"Interface: IBrowserInfo",sidebar_label:"IBrowserInfo",custom_edit_url:null},s=void 0,i={unversionedId:"api/interfaces/core_src.IBrowserInfo",id:"api/interfaces/core_src.IBrowserInfo",title:"Interface: IBrowserInfo",description:"This data structure contains the input configuration for the browser and",source:"@site/docs/api/interfaces/core_src.IBrowserInfo.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IBrowserInfo",title:"Interface: IBrowserInfo",sidebar_label:"IBrowserInfo",custom_edit_url:null},sidebar:"sidebar",previous:{title:"StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},next:{title:"IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge"}},l={},c=[{value:"Properties",id:"properties",level:2},{value:' _browserVersion: string',id:"-_browserversion-string",level:3},{value:' _consoleMessages: string[]',id:"-_consolemessages-string",level:3},{value:' _puppeteerConfig: LaunchOptions',id:"-_puppeteerconfig-launchoptions",level:3}],p={toc:c},u="wrapper";function g(e){let{components:r,...n}=e;return(0,o.yg)(u,(0,t.A)({},p,n,{components:r,mdxType:"MDXLayout"}),(0,o.yg)("p",null,"This data structure contains the input configuration for the browser and\noutput data from the browser. You can retrieve the instance of this type\nthrough ",(0,o.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#runmetainfo"},"RunMetaInfo"),"."),(0,o.yg)("h2",{id:"properties"},"Properties"),(0,o.yg)("h3",{id:"-_browserversion-string"},(0,o.yg)("a",{id:"\\_browserversion",name:"\\_browserversion"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","browserVersion"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"string")),(0,o.yg)("p",null,"browser version"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1232"},"core/src/lib/Types.ts:1232"))))),(0,o.yg)("hr",null),(0,o.yg)("h3",{id:"-_consolemessages-string"},(0,o.yg)("a",{id:"\\_consolemessages",name:"\\_consolemessages"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","consoleMessages"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"string"),"[]"),(0,o.yg)("p",null,"all web console output"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1240"},"core/src/lib/Types.ts:1240"))))),(0,o.yg)("hr",null),(0,o.yg)("h3",{id:"-_puppeteerconfig-launchoptions"},(0,o.yg)("a",{id:"\\_puppeteerconfig",name:"\\_puppeteerconfig"})," ",(0,o.yg)("strong",{parentName:"h3"},"_","puppeteerConfig"),": ",(0,o.yg)("inlineCode",{parentName:"h3"},"LaunchOptions")),(0,o.yg)("p",null,"configuration for puppeteer"),(0,o.yg)("ul",null,(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("strong",{parentName:"li"},"Source"),":",(0,o.yg)("ul",{parentName:"li"},(0,o.yg)("li",{parentName:"ul"},(0,o.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1236"},"core/src/lib/Types.ts:1236"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/4527bbe9.81ee2013.js b/assets/js/4527bbe9.46c3ba3a.js similarity index 98% rename from assets/js/4527bbe9.81ee2013.js rename to assets/js/4527bbe9.46c3ba3a.js index f4679c70..5a34fb9a 100644 --- a/assets/js/4527bbe9.81ee2013.js +++ b/assets/js/4527bbe9.46c3ba3a.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2625],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var l=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function t(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,l)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=l.createContext({}),p=function(e){var a=l.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return l.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return l.createElement(l.Fragment,{},a)}},u=l.forwardRef((function(e,a){var n=e.components,s=e.mdxType,t=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=s,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||t;return n?l.createElement(g,i(i({ref:a},y),{},{components:n})):l.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var t=n.length,i=new Array(t);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>t,metadata:()=>r,toc:()=>p});var l=n(8168),s=(n(6540),n(5680));const t={id:"heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",sidebar_label:"GlobalVariableAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.GlobalVariableAnalysis",id:"api/classes/heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",sidebar_label:"GlobalVariableAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},next:{title:"ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new GlobalVariableAnalysis()',id:"new-globalvariableanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,l.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"GlobalVariableAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-globalvariableanalysis"},(0,s.yg)("a",{id:"new globalvariableanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new GlobalVariableAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.ts#L25"},"heap-analysis/src/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.ts:25"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2625],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var l=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function t(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,l)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=l.createContext({}),p=function(e){var a=l.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return l.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return l.createElement(l.Fragment,{},a)}},u=l.forwardRef((function(e,a){var n=e.components,s=e.mdxType,t=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=s,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||t;return n?l.createElement(g,i(i({ref:a},y),{},{components:n})):l.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var t=n.length,i=new Array(t);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>t,metadata:()=>r,toc:()=>p});var l=n(8168),s=(n(6540),n(5680));const t={id:"heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",sidebar_label:"GlobalVariableAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.GlobalVariableAnalysis",id:"api/classes/heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.GlobalVariableAnalysis",title:"Class: GlobalVariableAnalysis",sidebar_label:"GlobalVariableAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},next:{title:"ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new GlobalVariableAnalysis()',id:"new-globalvariableanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,l.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"GlobalVariableAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-globalvariableanalysis"},(0,s.yg)("a",{id:"new globalvariableanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new GlobalVariableAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.ts#L25"},"heap-analysis/src/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.ts:25"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/5a17db6f.1d864fde.js b/assets/js/5a17db6f.ed14df67.js similarity index 98% rename from assets/js/5a17db6f.1d864fde.js rename to assets/js/5a17db6f.ed14df67.js index cc3e64d8..acf3a85e 100644 --- a/assets/js/5a17db6f.1d864fde.js +++ b/assets/js/5a17db6f.ed14df67.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8807],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=s,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||l;return n?t.createElement(g,i(i({ref:a},y),{},{components:n})):t.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var l=n.length,i=new Array(l);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",sidebar_label:"ObjectSizeAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectSizeAnalysis",id:"api/classes/heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",sidebar_label:"ObjectSizeAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},next:{title:"ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectSizeAnalysis()',id:"new-objectsizeanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectSizeAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectsizeanalysis"},(0,s.yg)("a",{id:"new objectsizeanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectSizeAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectSizeAnalysis.ts#L20"},"heap-analysis/src/plugins/ObjectSizeAnalysis.ts:20"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8807],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=s,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||l;return n?t.createElement(g,i(i({ref:a},y),{},{components:n})):t.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var l=n.length,i=new Array(l);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",sidebar_label:"ObjectSizeAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectSizeAnalysis",id:"api/classes/heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectSizeAnalysis",title:"Class: ObjectSizeAnalysis",sidebar_label:"ObjectSizeAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},next:{title:"ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectSizeAnalysis()',id:"new-objectsizeanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectSizeAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectsizeanalysis"},(0,s.yg)("a",{id:"new objectsizeanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectSizeAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectSizeAnalysis.ts#L20"},"heap-analysis/src/plugins/ObjectSizeAnalysis.ts:20"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/5b1d4bc5.6137fd8c.js b/assets/js/5b1d4bc5.c90c1034.js similarity index 97% rename from assets/js/5b1d4bc5.6137fd8c.js rename to assets/js/5b1d4bc5.c90c1034.js index a4e479d8..483847c2 100644 --- a/assets/js/5b1d4bc5.6137fd8c.js +++ b/assets/js/5b1d4bc5.c90c1034.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9439],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>d});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),r=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},m=function(e){var a=r(e.components);return s.createElement(o.Provider,{value:a},e.children)},y="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},h=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),y=r(n),h=t,d=y["".concat(o,".").concat(h)]||y[h]||g[h]||l;return n?s.createElement(d,i(i({ref:a},m),{},{components:n})):s.createElement(d,i({ref:a},m))}));function d(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=h;var p={};for(var o in a)hasOwnProperty.call(a,o)&&(p[o]=a[o]);p.originalType=e,p[y]="string"==typeof e?e:t,i[1]=p;for(var r=2;r{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>g,frontMatter:()=>l,metadata:()=>p,toc:()=>r});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src",title:"Package: @memlab/heap-analysis",sidebar_label:"heap-analysis/src",sidebar_position:0,custom_edit_url:null},i=void 0,p={unversionedId:"api/modules/heap_analysis_src",id:"api/modules/heap_analysis_src",title:"Package: @memlab/heap-analysis",description:"Classes",source:"@site/docs/api/modules/heap_analysis_src.md",sourceDirName:"api/modules",slug:"/api/modules/heap_analysis_src",permalink:"/memlab/docs/api/modules/heap_analysis_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"heap_analysis_src",title:"Package: @memlab/heap-analysis",sidebar_label:"heap-analysis/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"core/src",permalink:"/memlab/docs/api/modules/core_src"},next:{title:"ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode"}},o={},r=[{value:"Classes",id:"classes",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' AnalyzeSnapshotResult: Object',id:"-analyzesnapshotresult-object",level:3},{value:' HeapAnalysisOptions: Object',id:"-heapanalysisoptions-object",level:3},{value:' RunHeapAnalysisOptions: Object',id:"-runheapanalysisoptions-object",level:3},{value:"Functions",id:"functions",level:2},{value:'getDominatorNodes(ids, snapshot)',id:"getdominatornodesids-snapshot",level:3},{value:'getFullHeapFromFile(file)',id:"getfullheapfromfilefile",level:3},{value:'getHeapFromFile(file)',id:"getheapfromfilefile",level:3},{value:'getSnapshotDirForAnalysis(options)',id:"getsnapshotdirforanalysisoptions",level:3},{value:'getSnapshotFileForAnalysis(options)',id:"getsnapshotfileforanalysisoptions",level:3},{value:'loadHeapSnapshot(options)',id:"loadheapsnapshotoptions",level:3},{value:'snapshotMapReduce<T1, T2>(mapCallback, reduceCallback, options)',id:"snapshotmapreducet1-t2mapcallback-reducecallback-options",level:3},{value:"Type parameters",id:"type-parameters",level:4},{value:'takeNodeFullHeap()',id:"takenodefullheap",level:3}],m={toc:r},y="wrapper";function g(e){let{components:a,...n}=e;return(0,t.yg)(y,(0,s.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"classes"},"Classes"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},"BaseAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},"CollectionsHoldingStaleAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},"DetachedDOMElementAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},"GlobalVariableAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},"ObjectFanoutAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},"ObjectShallowAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},"ObjectShapeAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},"ObjectSizeAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},"ObjectUnboundGrowthAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},"ShapeUnboundGrowthAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},"StringAnalysis"))),(0,t.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,t.yg)("h3",{id:"-analyzesnapshotresult-object"},(0,t.yg)("a",{id:"analyzesnapshotresult",name:"analyzesnapshotresult"})," ",(0,t.yg)("strong",{parentName:"h3"},"AnalyzeSnapshotResult"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the return type from calling ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotfromfile"},"analyzeSnapshotFromFile"),"\nor ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotsindirectory"},"analyzeSnapshotsInDirectory"),"."),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"analysisOutputFile")),(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"string")),(0,t.yg)("td",{parentName:"tr",align:"left"},"file path of the console output of the heap analysis call")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L93"},"heap-analysis/src/PluginUtils.ts:93"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-heapanalysisoptions-object"},(0,t.yg)("a",{id:"heapanalysisoptions",name:"heapanalysisoptions"})," ",(0,t.yg)("strong",{parentName:"h3"},"HeapAnalysisOptions"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the auto-generated arguments passed to all the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nthat your self-defined heap analysis should implement.\nYou are not supposed to construct instances of this class."),(0,t.yg)("p",null,"For code examples on how this options could be used, see\n",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#getsnapshotfileforanalysis"},"getSnapshotFileForAnalysis"),", ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#loadheapsnapshot"},"loadHeapSnapshot"),",\nor ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#snapshotmapreduce"},"snapshotMapReduce"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L70"},"heap-analysis/src/PluginUtils.ts:70"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-runheapanalysisoptions-object"},(0,t.yg)("a",{id:"runheapanalysisoptions",name:"runheapanalysisoptions"})," ",(0,t.yg)("strong",{parentName:"h3"},"RunHeapAnalysisOptions"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the input option for ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotfromfile"},"analyzeSnapshotFromFile"),"\nand ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotsindirectory"},"analyzeSnapshotsInDirectory"),"."),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"workDir?")),(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"string")),(0,t.yg)("td",{parentName:"tr",align:"left"},"specify the working directory to where the intermediate, logging, and output files should be saved")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L81"},"heap-analysis/src/PluginUtils.ts:81"))))),(0,t.yg)("h2",{id:"functions"},"Functions"),(0,t.yg)("h3",{id:"getdominatornodesids-snapshot"},(0,t.yg)("a",{id:"getdominatornodes"}),(0,t.yg)("strong",{parentName:"h3"},"getDominatorNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"ids"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"snapshot"),")"),(0,t.yg)("p",null,"This API calculate the set of\n",(0,t.yg)("a",{parentName:"p",href:"https://firefox-source-docs.mozilla.org/devtools-user/memory/dominators/index.html"},"dominator nodes"),"\nof the set of input heap objects."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"number"),">"," | Set of ids of heap objects (or nodes)"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot")," | heap loaded from a heap snapshot"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"number"),">"," | the set of dominator nodes/objects"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile, getDominatorNodes} from '@memlab/heap-analysis';\n\nclass TestObject {}\n\n(async function () {\n const t1 = new TestObject();\n const t2 = new TestObject();\n\n // dump the heap of this running JavaScript program\n const heapFile = dumpNodeHeapSnapshot();\n const heap = await getFullHeapFromFile(heapFile);\n\n // find the heap node for TestObject\n let nodes = [];\n heap.nodes.forEach(node => {\n if (node.name === 'TestObject' && node.type === 'object') {\n nodes.push(node);\n }\n });\n\n // get the dominator nodes\n const dominatorIds = getDominatorNodes(\n new Set(nodes.map(node => node.id)),\n heap,\n );\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L757"},"heap-analysis/src/PluginUtils.ts:757"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getfullheapfromfilefile"},(0,t.yg)("a",{id:"getfullheapfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"getFullHeapFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),")"),(0,t.yg)("p",null,"Load and parse a ",(0,t.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file and calculate meta data like\ndominator nodes and retained sizes."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"," | the heap graph representation instance that supports querying\nthe heap"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function (){\n const heapFile = dumpNodeHeapSnapshot();\n const heap = await getFullHeapFromFile(heapFile);\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L554"},"heap-analysis/src/PluginUtils.ts:554"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getheapfromfilefile"},(0,t.yg)("a",{id:"getheapfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"getHeapFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),")"),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"deprecated"))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L585"},"heap-analysis/src/PluginUtils.ts:585"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getsnapshotdirforanalysisoptions"},(0,t.yg)("a",{id:"getsnapshotdirforanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"getSnapshotDirForAnalysis"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Get the absolute path of the directory holding all the heap snapshot files\npassed to the hosting heap analysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the overridden ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Nullable"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"string"),">"," | the absolute path of the directory"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {getSnapshotFileForAnalysis, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const directory = getSnapshotDirForAnalysis(options);\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"getSnapshotDirForAnalysis")," use the snapshot directory from\n",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L466"},"heap-analysis/src/PluginUtils.ts:466"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getsnapshotfileforanalysisoptions"},(0,t.yg)("a",{id:"getsnapshotfileforanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"getSnapshotFileForAnalysis"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Get the heap snapshot file's absolute path passed to the hosting heap\nanalysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the overridden ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the heap snapshot file"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {getSnapshotFileForAnalysis, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const file = getSnapshotFileForAnalysis(options);\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"getSnapshotFileForAnalysis")," will use the last heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L417"},"heap-analysis/src/PluginUtils.ts:417"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"loadheapsnapshotoptions"},(0,t.yg)("a",{id:"loadheapsnapshot"}),(0,t.yg)("strong",{parentName:"h3"},"loadHeapSnapshot"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Load the heap graph based on the single JavaScript heap snapshot\npassed to the hosting heap analysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," implementation\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"," | the graph representation of the heap"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {loadHeapSnapshot, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const heap = await loadHeapSnapshot(options);\n // doing heap analysis\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"loadHeapSnapshot")," will use the last heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L520"},"heap-analysis/src/PluginUtils.ts:520"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"snapshotmapreducet1-t2mapcallback-reducecallback-options"},(0,t.yg)("a",{id:"snapshotmapreduce"}),(0,t.yg)("strong",{parentName:"h3"},"snapshotMapReduce"),"<",(0,t.yg)("inlineCode",{parentName:"h3"},"T1"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"T2"),">","(",(0,t.yg)("inlineCode",{parentName:"h3"},"mapCallback"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"reduceCallback"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"When a heap analysis is taking multiple heap snapshots as input for memory\nanalysis (e.g., finding which object keeps growing in size in a series of\nheap snapshots), this API could be used to do\n",(0,t.yg)("a",{parentName:"p",href:"https://en.wikipedia.org/wiki/MapReduce"},"MapRedue")," on all heap snapshots."),(0,t.yg)("p",null,"This API is supposed to be used within the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," implementation\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance that is designed to analyze multiple heap\nsnapshots (as an example, finding which object keeps growing overtime)"),(0,t.yg)("h4",{id:"type-parameters"},"Type parameters"),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"T1")),(0,t.yg)("td",{parentName:"tr",align:"left"},"the type of the intermediate result from each map function call")),(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"T2")),(0,t.yg)("td",{parentName:"tr",align:"left"},"the type of the final result of the reduce function call")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"mapCallback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),", ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"T1")," | the map function in MapReduce, the function will be applied to each heap snapshot"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"reduceCallback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"results"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"T1"),"[]) => ",(0,t.yg)("inlineCode",{parentName:"li"},"T2")," | the reduce function in MapReduce, the function will take as input all intermediate results from all map function calls"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"T2"),">"," | the return value of your reduce function"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {snapshotMapReduce, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n // check if the number of heap objects keeps growing overtime\n const isMonotonicIncreasing = await snapshotMapReduce(\n (heap) => heap.nodes.length,\n (nodeCounts) =>\n nodeCounts[0] < nodeCounts[nodeCounts.length - 1] &&\n nodeCounts.every((count, i) => i === 0 || count >= nodeCounts[i - 1]),\n options,\n );\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// snapshotDir includes a series of .heapsnapshot files recorded by\n// memlab or saved manually from Chrome, those files will be loaded\n// in alphanumerically ascending order\nawait analysis.analyzeSnapshotsInDirectory(snapshotDir);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"snapshotMapReduce")," will use all the heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},"Why not passing in all heap snapshots as an array of ",(0,t.yg)("a",{parentName:"strong",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),"s?"),"\nEach heap snapshot could be non-trivial in size, loading them all at once\nmay not be possible."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L662"},"heap-analysis/src/PluginUtils.ts:662"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"takenodefullheap"},(0,t.yg)("a",{id:"takenodefullheap"}),(0,t.yg)("strong",{parentName:"h3"},"takeNodeFullHeap"),"()"),(0,t.yg)("p",null,"Take a heap snapshot of the current program state\nand parse it as ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),". This\nAPI also calculates some heap analysis meta data\nfor heap analysis. But this also means slower heap parsing\ncomparing with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#takenodeminimalheap"},"takeNodeMinimalHeap"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapSnapshot"),">"," | heap representation with heap analysis meta data.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples:")))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {takeNodeFullHeap} from '@memlab/heap-analysis';\n\n(async function () {\n const heap: IHeapSnapshot = await takeNodeFullHeap();\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/PluginUtils.ts#L577"},"heap-analysis/src/PluginUtils.ts:577"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9439],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>d});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),r=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},m=function(e){var a=r(e.components);return s.createElement(o.Provider,{value:a},e.children)},y="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},h=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),y=r(n),h=t,d=y["".concat(o,".").concat(h)]||y[h]||g[h]||l;return n?s.createElement(d,i(i({ref:a},m),{},{components:n})):s.createElement(d,i({ref:a},m))}));function d(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=h;var p={};for(var o in a)hasOwnProperty.call(a,o)&&(p[o]=a[o]);p.originalType=e,p[y]="string"==typeof e?e:t,i[1]=p;for(var r=2;r{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>g,frontMatter:()=>l,metadata:()=>p,toc:()=>r});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src",title:"Package: @memlab/heap-analysis",sidebar_label:"heap-analysis/src",sidebar_position:0,custom_edit_url:null},i=void 0,p={unversionedId:"api/modules/heap_analysis_src",id:"api/modules/heap_analysis_src",title:"Package: @memlab/heap-analysis",description:"Classes",source:"@site/docs/api/modules/heap_analysis_src.md",sourceDirName:"api/modules",slug:"/api/modules/heap_analysis_src",permalink:"/memlab/docs/api/modules/heap_analysis_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"heap_analysis_src",title:"Package: @memlab/heap-analysis",sidebar_label:"heap-analysis/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"core/src",permalink:"/memlab/docs/api/modules/core_src"},next:{title:"ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode"}},o={},r=[{value:"Classes",id:"classes",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' AnalyzeSnapshotResult: Object',id:"-analyzesnapshotresult-object",level:3},{value:' HeapAnalysisOptions: Object',id:"-heapanalysisoptions-object",level:3},{value:' RunHeapAnalysisOptions: Object',id:"-runheapanalysisoptions-object",level:3},{value:"Functions",id:"functions",level:2},{value:'getDominatorNodes(ids, snapshot)',id:"getdominatornodesids-snapshot",level:3},{value:'getFullHeapFromFile(file)',id:"getfullheapfromfilefile",level:3},{value:'getHeapFromFile(file)',id:"getheapfromfilefile",level:3},{value:'getSnapshotDirForAnalysis(options)',id:"getsnapshotdirforanalysisoptions",level:3},{value:'getSnapshotFileForAnalysis(options)',id:"getsnapshotfileforanalysisoptions",level:3},{value:'loadHeapSnapshot(options)',id:"loadheapsnapshotoptions",level:3},{value:'snapshotMapReduce<T1, T2>(mapCallback, reduceCallback, options)',id:"snapshotmapreducet1-t2mapcallback-reducecallback-options",level:3},{value:"Type parameters",id:"type-parameters",level:4},{value:'takeNodeFullHeap()',id:"takenodefullheap",level:3}],m={toc:r},y="wrapper";function g(e){let{components:a,...n}=e;return(0,t.yg)(y,(0,s.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"classes"},"Classes"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},"BaseAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis"},"CollectionsHoldingStaleAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"},"DetachedDOMElementAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},"GlobalVariableAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},"ObjectFanoutAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},"ObjectShallowAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"},"ObjectShapeAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"},"ObjectSizeAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},"ObjectUnboundGrowthAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis"},"ShapeUnboundGrowthAnalysis")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"},"StringAnalysis"))),(0,t.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,t.yg)("h3",{id:"-analyzesnapshotresult-object"},(0,t.yg)("a",{id:"analyzesnapshotresult",name:"analyzesnapshotresult"})," ",(0,t.yg)("strong",{parentName:"h3"},"AnalyzeSnapshotResult"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the return type from calling ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotfromfile"},"analyzeSnapshotFromFile"),"\nor ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotsindirectory"},"analyzeSnapshotsInDirectory"),"."),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"analysisOutputFile")),(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"string")),(0,t.yg)("td",{parentName:"tr",align:"left"},"file path of the console output of the heap analysis call")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L93"},"heap-analysis/src/PluginUtils.ts:93"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-heapanalysisoptions-object"},(0,t.yg)("a",{id:"heapanalysisoptions",name:"heapanalysisoptions"})," ",(0,t.yg)("strong",{parentName:"h3"},"HeapAnalysisOptions"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the auto-generated arguments passed to all the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nthat your self-defined heap analysis should implement.\nYou are not supposed to construct instances of this class."),(0,t.yg)("p",null,"For code examples on how this options could be used, see\n",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#getsnapshotfileforanalysis"},"getSnapshotFileForAnalysis"),", ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#loadheapsnapshot"},"loadHeapSnapshot"),",\nor ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/heap_analysis_src#snapshotmapreduce"},"snapshotMapReduce"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L70"},"heap-analysis/src/PluginUtils.ts:70"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-runheapanalysisoptions-object"},(0,t.yg)("a",{id:"runheapanalysisoptions",name:"runheapanalysisoptions"})," ",(0,t.yg)("strong",{parentName:"h3"},"RunHeapAnalysisOptions"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"Object")),(0,t.yg)("p",null,"This is the input option for ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotfromfile"},"analyzeSnapshotFromFile"),"\nand ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis#analyzesnapshotsindirectory"},"analyzeSnapshotsInDirectory"),"."),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"workDir?")),(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"string")),(0,t.yg)("td",{parentName:"tr",align:"left"},"specify the working directory to where the intermediate, logging, and output files should be saved")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L81"},"heap-analysis/src/PluginUtils.ts:81"))))),(0,t.yg)("h2",{id:"functions"},"Functions"),(0,t.yg)("h3",{id:"getdominatornodesids-snapshot"},(0,t.yg)("a",{id:"getdominatornodes"}),(0,t.yg)("strong",{parentName:"h3"},"getDominatorNodes"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"ids"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"snapshot"),")"),(0,t.yg)("p",null,"This API calculate the set of\n",(0,t.yg)("a",{parentName:"p",href:"https://firefox-source-docs.mozilla.org/devtools-user/memory/dominators/index.html"},"dominator nodes"),"\nof the set of input heap objects."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"number"),">"," | Set of ids of heap objects (or nodes)"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot")," | heap loaded from a heap snapshot"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"number"),">"," | the set of dominator nodes/objects"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile, getDominatorNodes} from '@memlab/heap-analysis';\n\nclass TestObject {}\n\n(async function () {\n const t1 = new TestObject();\n const t2 = new TestObject();\n\n // dump the heap of this running JavaScript program\n const heapFile = dumpNodeHeapSnapshot();\n const heap = await getFullHeapFromFile(heapFile);\n\n // find the heap node for TestObject\n let nodes = [];\n heap.nodes.forEach(node => {\n if (node.name === 'TestObject' && node.type === 'object') {\n nodes.push(node);\n }\n });\n\n // get the dominator nodes\n const dominatorIds = getDominatorNodes(\n new Set(nodes.map(node => node.id)),\n heap,\n );\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L757"},"heap-analysis/src/PluginUtils.ts:757"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getfullheapfromfilefile"},(0,t.yg)("a",{id:"getfullheapfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"getFullHeapFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),")"),(0,t.yg)("p",null,"Load and parse a ",(0,t.yg)("inlineCode",{parentName:"p"},".heapsnapshot")," file and calculate meta data like\ndominator nodes and retained sizes."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"," | the heap graph representation instance that supports querying\nthe heap"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function (){\n const heapFile = dumpNodeHeapSnapshot();\n const heap = await getFullHeapFromFile(heapFile);\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L554"},"heap-analysis/src/PluginUtils.ts:554"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getheapfromfilefile"},(0,t.yg)("a",{id:"getheapfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"getHeapFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),")"),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"deprecated"))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L585"},"heap-analysis/src/PluginUtils.ts:585"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getsnapshotdirforanalysisoptions"},(0,t.yg)("a",{id:"getsnapshotdirforanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"getSnapshotDirForAnalysis"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Get the absolute path of the directory holding all the heap snapshot files\npassed to the hosting heap analysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the overridden ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Nullable"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"string"),">"," | the absolute path of the directory"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {getSnapshotFileForAnalysis, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const directory = getSnapshotDirForAnalysis(options);\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"getSnapshotDirForAnalysis")," use the snapshot directory from\n",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L466"},"heap-analysis/src/PluginUtils.ts:466"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getsnapshotfileforanalysisoptions"},(0,t.yg)("a",{id:"getsnapshotfileforanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"getSnapshotFileForAnalysis"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Get the heap snapshot file's absolute path passed to the hosting heap\nanalysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the overridden ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," method\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the heap snapshot file"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {getSnapshotFileForAnalysis, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const file = getSnapshotFileForAnalysis(options);\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"getSnapshotFileForAnalysis")," will use the last heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L417"},"heap-analysis/src/PluginUtils.ts:417"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"loadheapsnapshotoptions"},(0,t.yg)("a",{id:"loadheapsnapshot"}),(0,t.yg)("strong",{parentName:"h3"},"loadHeapSnapshot"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"Load the heap graph based on the single JavaScript heap snapshot\npassed to the hosting heap analysis via ",(0,t.yg)("inlineCode",{parentName:"p"},"HeapAnalysisOptions"),"."),(0,t.yg)("p",null,"This API is supposed to be used within the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," implementation\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),">"," | the graph representation of the heap"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {loadHeapSnapshot, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n const heap = await loadHeapSnapshot(options);\n // doing heap analysis\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// any .heapsnapshot file recorded by memlab or saved manually from Chrome\nawait analysis.analyzeSnapshotFromFile(snapshotFile);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"loadHeapSnapshot")," will use the last heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L520"},"heap-analysis/src/PluginUtils.ts:520"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"snapshotmapreducet1-t2mapcallback-reducecallback-options"},(0,t.yg)("a",{id:"snapshotmapreduce"}),(0,t.yg)("strong",{parentName:"h3"},"snapshotMapReduce"),"<",(0,t.yg)("inlineCode",{parentName:"h3"},"T1"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"T2"),">","(",(0,t.yg)("inlineCode",{parentName:"h3"},"mapCallback"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"reduceCallback"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options"),")"),(0,t.yg)("p",null,"When a heap analysis is taking multiple heap snapshots as input for memory\nanalysis (e.g., finding which object keeps growing in size in a series of\nheap snapshots), this API could be used to do\n",(0,t.yg)("a",{parentName:"p",href:"https://en.wikipedia.org/wiki/MapReduce"},"MapRedue")," on all heap snapshots."),(0,t.yg)("p",null,"This API is supposed to be used within the ",(0,t.yg)("inlineCode",{parentName:"p"},"process")," implementation\nof an ",(0,t.yg)("inlineCode",{parentName:"p"},"BaseAnalysis")," instance that is designed to analyze multiple heap\nsnapshots (as an example, finding which object keeps growing overtime)"),(0,t.yg)("h4",{id:"type-parameters"},"Type parameters"),(0,t.yg)("table",null,(0,t.yg)("thead",{parentName:"table"},(0,t.yg)("tr",{parentName:"thead"},(0,t.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,t.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,t.yg)("tbody",{parentName:"table"},(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"T1")),(0,t.yg)("td",{parentName:"tr",align:"left"},"the type of the intermediate result from each map function call")),(0,t.yg)("tr",{parentName:"tbody"},(0,t.yg)("td",{parentName:"tr",align:"left"},(0,t.yg)("inlineCode",{parentName:"td"},"T2")),(0,t.yg)("td",{parentName:"tr",align:"left"},"the type of the final result of the reduce function call")))),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"mapCallback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"IHeapSnapshot"),", ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),", ",(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"T1")," | the map function in MapReduce, the function will be applied to each heap snapshot"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"reduceCallback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"results"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"T1"),"[]) => ",(0,t.yg)("inlineCode",{parentName:"li"},"T2")," | the reduce function in MapReduce, the function will take as input all intermediate results from all map function calls"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#heapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"HeapAnalysisOptions"))," | this is the auto-generated input passed to all the ",(0,t.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," instances"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"li"},"T2"),">"," | the return value of your reduce function"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples:"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {HeapAnalysisOptions} from '@memlab/heap-analysis';\nimport {snapshotMapReduce, BaseAnalysis} from '@memlab/heap-analysis';\n\nclass ExampleAnalysis extends BaseAnalysis {\n public getCommandName(): string {\n return 'example-analysis';\n }\n\n public getDescription(): string {\n return 'an example analysis for demo';\n }\n\n async process(options: HeapAnalysisOptions): Promise {\n // check if the number of heap objects keeps growing overtime\n const isMonotonicIncreasing = await snapshotMapReduce(\n (heap) => heap.nodes.length,\n (nodeCounts) =>\n nodeCounts[0] < nodeCounts[nodeCounts.length - 1] &&\n nodeCounts.every((count, i) => i === 0 || count >= nodeCounts[i - 1]),\n options,\n );\n }\n}\n")),(0,t.yg)("p",null,"Use the following code to invoke the heap analysis:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ExampleAnalysis();\n// snapshotDir includes a series of .heapsnapshot files recorded by\n// memlab or saved manually from Chrome, those files will be loaded\n// in alphanumerically ascending order\nawait analysis.analyzeSnapshotsInDirectory(snapshotDir);\n")),(0,t.yg)("p",null,"The new heap analysis can also be used with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#analyze"},"analyze"),", in that case\n",(0,t.yg)("inlineCode",{parentName:"p"},"snapshotMapReduce")," will use all the heap snapshot in alphanumerically\nascending order from ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader"),"."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},"Why not passing in all heap snapshots as an array of ",(0,t.yg)("a",{parentName:"strong",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),"s?"),"\nEach heap snapshot could be non-trivial in size, loading them all at once\nmay not be possible."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L662"},"heap-analysis/src/PluginUtils.ts:662"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"takenodefullheap"},(0,t.yg)("a",{id:"takenodefullheap"}),(0,t.yg)("strong",{parentName:"h3"},"takeNodeFullHeap"),"()"),(0,t.yg)("p",null,"Take a heap snapshot of the current program state\nand parse it as ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"),". This\nAPI also calculates some heap analysis meta data\nfor heap analysis. But this also means slower heap parsing\ncomparing with ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#takenodeminimalheap"},"takeNodeMinimalHeap"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapSnapshot"),">"," | heap representation with heap analysis meta data.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples:")))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport type {takeNodeFullHeap} from '@memlab/heap-analysis';\n\n(async function () {\n const heap: IHeapSnapshot = await takeNodeFullHeap();\n})();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/PluginUtils.ts#L577"},"heap-analysis/src/PluginUtils.ts:577"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/5be78946.b2dc5a65.js b/assets/js/5be78946.84581dc3.js similarity index 98% rename from assets/js/5be78946.b2dc5a65.js rename to assets/js/5be78946.84581dc3.js index ecbad380..3ffcc0bd 100644 --- a/assets/js/5be78946.b2dc5a65.js +++ b/assets/js/5be78946.84581dc3.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8485],{5680:(e,a,n)=>{n.d(a,{xA:()=>p,yg:()=>g});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var s=r.createContext({}),c=function(e){var a=r.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},p=function(e){var a=c(e.components);return r.createElement(s.Provider,{value:a},e.children)},d="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},f=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,s=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),d=c(n),f=t,g=d["".concat(s,".").concat(f)]||d[f]||m[f]||l;return n?r.createElement(g,i(i({ref:a},p),{},{components:n})):r.createElement(g,i({ref:a},p))}));function g(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=f;var o={};for(var s in a)hasOwnProperty.call(a,s)&&(o[s]=a[s]);o.originalType=e,o[d]="string"==typeof e?e:t,i[1]=o;for(var c=2;c{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>o,toc:()=>c});var r=n(8168),t=(n(6540),n(5680));const l={id:"core_src.ILeakFilter",title:"Interface: ILeakFilter",sidebar_label:"ILeakFilter",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.ILeakFilter",id:"api/interfaces/core_src.ILeakFilter",title:"Interface: ILeakFilter",description:"The ILeakFilter interface allows you to define a leak detector and",source:"@site/docs/api/interfaces/core_src.ILeakFilter.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.ILeakFilter",title:"Interface: ILeakFilter",sidebar_label:"ILeakFilter",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},next:{title:"IScenario",permalink:"/memlab/docs/api/interfaces/core_src.IScenario"}},s={},c=[{value:"Properties",id:"properties",level:2},{value:' Optional beforeLeakFilter: InitLeakFilterCallback',id:"-optional-beforeleakfilter-initleakfiltercallback",level:3},{value:' Optional leakFilter: LeakFilterCallback',id:"-optional-leakfilter-leakfiltercallback",level:3},{value:' Optional retainerReferenceFilter: ReferenceFilterCallback',id:"-optional-retainerreferencefilter-referencefiltercallback",level:3}],p={toc:c},d="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},p,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"The ",(0,t.yg)("inlineCode",{parentName:"p"},"ILeakFilter")," interface allows you to define a leak detector and\ncustomize the leak filtering logic in memlab (instead of using the\nbuilt-in leak filters)."),(0,t.yg)("p",null,"Use the leak filter definition in command line interface to filter\nleaks detected from browser interactions"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("p",null,"If you have already run ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab run")," or ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab snapshot")," which saved\nheap snapshot and other meta data on disk, use the following command\nto filter leaks based on those saved heap snapshots (query the default\ndata location by ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab get-default-work-dir"),")."),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("p",null,"Here is an example TypeScript file defining a leak filter.\nThe command line interface only accepts compiled JavaScript file.\nYou can also define the leak filter in JavaScript (without the\ntype annotations."),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {IHeapNode, IHeapSnapshot, HeapNodeIdSet, utils} from '@memlab/core';\n\nfunction initMap(snapshot: IHeapSnapshot): Record {\n const map = Object.create(null);\n snapshot.nodes.forEach(node => {\n if (node.type !== 'string') {\n return;\n }\n const str = utils.getStringNodeValue(node);\n if (str in map) {\n ++map[str];\n } else {\n map[str] = 1;\n }\n });\n return map;\n}\nconst beforeLeakFilter = (snapshot: IHeapSnapshot, _leakedNodeIds: HeapNodeIdSet): void => {\n map = initMap(snapshot);\n};\n\n// duplicated string with size > 1KB as memory leak\nconst leakFilter = (node: IHeapNode): boolean => {\n if (node.type !== 'string' || node.retainedSize < 1000) {\n return false;\n }\n const str = utils.getStringNodeValue(node);\n return map[str] > 1;\n};\n\nexport default {beforeLeakFilter, leakFilter};\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-optional-beforeleakfilter-initleakfiltercallback"},(0,t.yg)("a",{id:"beforeleakfilter",name:"beforeleakfilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"beforeLeakFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#initleakfiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"InitLeakFilterCallback"))),(0,t.yg)("p",null,"Lifecycle function callback that is invoked initially once before\nthe subsequent ",(0,t.yg)("inlineCode",{parentName:"p"},"leakFilter")," function calls. This callback could\nbe used to initialize some data stores or any one-off\npreprocessings."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,t.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,t.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"module.exports = {\n beforeLeakFilter: (snapshot, leakedNodeIds) {\n // initialize some data stores\n },\n leakFilter(node, snapshot, leakedNodeIds) {\n // use the data stores\n },\n};\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L428"},"core/src/lib/Types.ts:428"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-optional-leakfilter-leakfiltercallback"},(0,t.yg)("a",{id:"leakfilter",name:"leakfilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"leakFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#leakfiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"LeakFilterCallback"))),(0,t.yg)("p",null,"This callback defines how you want to filter out the\nleaked objects. The callback is called for every node (JS heap\nobject in browser) allocated by the ",(0,t.yg)("inlineCode",{parentName:"p"},"action")," callback, but not\nreleased after the ",(0,t.yg)("inlineCode",{parentName:"p"},"back")," callback. Those objects could be caches\nthat are retained in memory on purpose, or they are memory leaks."),(0,t.yg)("p",null,"This optional callback allows you to define your own algorithm\nto cherry pick memory leaks for specific JS program under test."),(0,t.yg)("p",null,"If this optional callback is not defined, memlab will use its\nbuilt-in leak filter, which considers detached DOM elements\nand unmounted Fiber nodes (detached from React Fiber tree) as\nmemory leaks."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode"))," | the heap object\nallocated but not released. This filter callback will be applied\nto each node allocated but not released in the heap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,t.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,t.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": the boolean value indicating whether the given node in\nthe snapshot should be considered as leaked.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n leakFilter(node, snapshot, leakedNodeIds) {\n // any unreleased node (JS heap object) with 1MB+\n // retained size is considered a memory leak\n return node.retainedSize > 1000000;\n },\n};\n")),(0,t.yg)("p",null,"Use the leak filter definition in command line interface:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L480"},"core/src/lib/Types.ts:480"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-optional-retainerreferencefilter-referencefiltercallback"},(0,t.yg)("a",{id:"retainerreferencefilter",name:"retainerreferencefilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"retainerReferenceFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#referencefiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"ReferenceFilterCallback"))),(0,t.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be considered as part of the retainer trace.\nThe callback is called for every reference (edge) in the heap snapshot."),(0,t.yg)("p",null,"For concrete examples, check out ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edge")," : ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"))," | the reference (edge)\nthat is considered for calcualting the retainer trace"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default\nlogic for whether a reference should be considered as part of the\nretainer trace, if this parameter is true, it means MemLab will\nconsider this reference when calculating the retainer trace."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": the value indicating whether the given reference should be\nconsidered when calculating the retainer trace. Note that when this\ncallback returns true, the reference will only be considered as a candidate\nfor retainer trace, so it may or may not be included in the retainer trace;\nhowever, if this callback returns false, the reference will be excluded."))),(0,t.yg)("p",null,"Note that by excluding a dominator reference of an object (i.e., an edge\nthat must be traveled through to reach the heap object from GC roots),\nthe object will be considered as unreachable in the heap graph; and\ntherefore, the reference and heap object will not be included in the\nretainer trace detection and retainer size calculation."),(0,t.yg)("p",null,"Please also be aware that some edges like self-referencing edges,\nJS engine's internal edges, and hidden edges should not be considered\nas part of the retainer trace. These edges could make the retainer trace\nunncessarily complex and cause confusion. ",(0,t.yg)("inlineCode",{parentName:"p"},"isReferenceUsedByDefault")," will\nbe ",(0,t.yg)("inlineCode",{parentName:"p"},"false")," for these types of edges."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n retainerReferenceFilter(edge, _snapshot, _isReferenceUsedByDefault) {\n // exclude react fiber references\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n // exclude other references here\n // ...\n return true;\n }\n};\n")),(0,t.yg)("p",null,"Use the leak filter definition in command line interface:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L543"},"core/src/lib/Types.ts:543"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8485],{5680:(e,a,n)=>{n.d(a,{xA:()=>p,yg:()=>g});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var s=r.createContext({}),c=function(e){var a=r.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},p=function(e){var a=c(e.components);return r.createElement(s.Provider,{value:a},e.children)},d="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},f=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,s=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),d=c(n),f=t,g=d["".concat(s,".").concat(f)]||d[f]||m[f]||l;return n?r.createElement(g,i(i({ref:a},p),{},{components:n})):r.createElement(g,i({ref:a},p))}));function g(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=f;var o={};for(var s in a)hasOwnProperty.call(a,s)&&(o[s]=a[s]);o.originalType=e,o[d]="string"==typeof e?e:t,i[1]=o;for(var c=2;c{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>o,toc:()=>c});var r=n(8168),t=(n(6540),n(5680));const l={id:"core_src.ILeakFilter",title:"Interface: ILeakFilter",sidebar_label:"ILeakFilter",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.ILeakFilter",id:"api/interfaces/core_src.ILeakFilter",title:"Interface: ILeakFilter",description:"The ILeakFilter interface allows you to define a leak detector and",source:"@site/docs/api/interfaces/core_src.ILeakFilter.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.ILeakFilter",title:"Interface: ILeakFilter",sidebar_label:"ILeakFilter",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"},next:{title:"IScenario",permalink:"/memlab/docs/api/interfaces/core_src.IScenario"}},s={},c=[{value:"Properties",id:"properties",level:2},{value:' Optional beforeLeakFilter: InitLeakFilterCallback',id:"-optional-beforeleakfilter-initleakfiltercallback",level:3},{value:' Optional leakFilter: LeakFilterCallback',id:"-optional-leakfilter-leakfiltercallback",level:3},{value:' Optional retainerReferenceFilter: ReferenceFilterCallback',id:"-optional-retainerreferencefilter-referencefiltercallback",level:3}],p={toc:c},d="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},p,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"The ",(0,t.yg)("inlineCode",{parentName:"p"},"ILeakFilter")," interface allows you to define a leak detector and\ncustomize the leak filtering logic in memlab (instead of using the\nbuilt-in leak filters)."),(0,t.yg)("p",null,"Use the leak filter definition in command line interface to filter\nleaks detected from browser interactions"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("p",null,"If you have already run ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab run")," or ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab snapshot")," which saved\nheap snapshot and other meta data on disk, use the following command\nto filter leaks based on those saved heap snapshots (query the default\ndata location by ",(0,t.yg)("inlineCode",{parentName:"p"},"memlab get-default-work-dir"),")."),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("p",null,"Here is an example TypeScript file defining a leak filter.\nThe command line interface only accepts compiled JavaScript file.\nYou can also define the leak filter in JavaScript (without the\ntype annotations."),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import {IHeapNode, IHeapSnapshot, HeapNodeIdSet, utils} from '@memlab/core';\n\nfunction initMap(snapshot: IHeapSnapshot): Record {\n const map = Object.create(null);\n snapshot.nodes.forEach(node => {\n if (node.type !== 'string') {\n return;\n }\n const str = utils.getStringNodeValue(node);\n if (str in map) {\n ++map[str];\n } else {\n map[str] = 1;\n }\n });\n return map;\n}\nconst beforeLeakFilter = (snapshot: IHeapSnapshot, _leakedNodeIds: HeapNodeIdSet): void => {\n map = initMap(snapshot);\n};\n\n// duplicated string with size > 1KB as memory leak\nconst leakFilter = (node: IHeapNode): boolean => {\n if (node.type !== 'string' || node.retainedSize < 1000) {\n return false;\n }\n const str = utils.getStringNodeValue(node);\n return map[str] > 1;\n};\n\nexport default {beforeLeakFilter, leakFilter};\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-optional-beforeleakfilter-initleakfiltercallback"},(0,t.yg)("a",{id:"beforeleakfilter",name:"beforeleakfilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"beforeLeakFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#initleakfiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"InitLeakFilterCallback"))),(0,t.yg)("p",null,"Lifecycle function callback that is invoked initially once before\nthe subsequent ",(0,t.yg)("inlineCode",{parentName:"p"},"leakFilter")," function calls. This callback could\nbe used to initialize some data stores or any one-off\npreprocessings."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,t.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,t.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"module.exports = {\n beforeLeakFilter: (snapshot, leakedNodeIds) {\n // initialize some data stores\n },\n leakFilter(node, snapshot, leakedNodeIds) {\n // use the data stores\n },\n};\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L428"},"core/src/lib/Types.ts:428"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-optional-leakfilter-leakfiltercallback"},(0,t.yg)("a",{id:"leakfilter",name:"leakfilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"leakFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#leakfiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"LeakFilterCallback"))),(0,t.yg)("p",null,"This callback defines how you want to filter out the\nleaked objects. The callback is called for every node (JS heap\nobject in browser) allocated by the ",(0,t.yg)("inlineCode",{parentName:"p"},"action")," callback, but not\nreleased after the ",(0,t.yg)("inlineCode",{parentName:"p"},"back")," callback. Those objects could be caches\nthat are retained in memory on purpose, or they are memory leaks."),(0,t.yg)("p",null,"This optional callback allows you to define your own algorithm\nto cherry pick memory leaks for specific JS program under test."),(0,t.yg)("p",null,"If this optional callback is not defined, memlab will use its\nbuilt-in leak filter, which considers detached DOM elements\nand unmounted Fiber nodes (detached from React Fiber tree) as\nmemory leaks."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode"))," | the heap object\nallocated but not released. This filter callback will be applied\nto each node allocated but not released in the heap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,t.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,t.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": the boolean value indicating whether the given node in\nthe snapshot should be considered as leaked.")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n leakFilter(node, snapshot, leakedNodeIds) {\n // any unreleased node (JS heap object) with 1MB+\n // retained size is considered a memory leak\n return node.retainedSize > 1000000;\n },\n};\n")),(0,t.yg)("p",null,"Use the leak filter definition in command line interface:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L480"},"core/src/lib/Types.ts:480"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-optional-retainerreferencefilter-referencefiltercallback"},(0,t.yg)("a",{id:"retainerreferencefilter",name:"retainerreferencefilter"})," ",(0,t.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,t.yg)("strong",{parentName:"h3"},"retainerReferenceFilter"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#referencefiltercallback"},(0,t.yg)("inlineCode",{parentName:"a"},"ReferenceFilterCallback"))),(0,t.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be considered as part of the retainer trace.\nThe callback is called for every reference (edge) in the heap snapshot."),(0,t.yg)("p",null,"For concrete examples, check out ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.ILeakFilter#leakfilter"},"leakFilter"),"."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"edge")," : ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"))," | the reference (edge)\nthat is considered for calcualting the retainer trace"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,t.yg)("code",null,(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default\nlogic for whether a reference should be considered as part of the\nretainer trace, if this parameter is true, it means MemLab will\nconsider this reference when calculating the retainer trace."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": the value indicating whether the given reference should be\nconsidered when calculating the retainer trace. Note that when this\ncallback returns true, the reference will only be considered as a candidate\nfor retainer trace, so it may or may not be included in the retainer trace;\nhowever, if this callback returns false, the reference will be excluded."))),(0,t.yg)("p",null,"Note that by excluding a dominator reference of an object (i.e., an edge\nthat must be traveled through to reach the heap object from GC roots),\nthe object will be considered as unreachable in the heap graph; and\ntherefore, the reference and heap object will not be included in the\nretainer trace detection and retainer size calculation."),(0,t.yg)("p",null,"Please also be aware that some edges like self-referencing edges,\nJS engine's internal edges, and hidden edges should not be considered\nas part of the retainer trace. These edges could make the retainer trace\nunncessarily complex and cause confusion. ",(0,t.yg)("inlineCode",{parentName:"p"},"isReferenceUsedByDefault")," will\nbe ",(0,t.yg)("inlineCode",{parentName:"p"},"false")," for these types of edges."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n retainerReferenceFilter(edge, _snapshot, _isReferenceUsedByDefault) {\n // exclude react fiber references\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n // exclude other references here\n // ...\n return true;\n }\n};\n")),(0,t.yg)("p",null,"Use the leak filter definition in command line interface:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab find-leaks --leak-filter \n")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-bash"},"memlab run --scenario --leak-filter \n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L543"},"core/src/lib/Types.ts:543"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/6b5d7254.1a2b0df8.js b/assets/js/6b5d7254.4c379e61.js similarity index 91% rename from assets/js/6b5d7254.1a2b0df8.js rename to assets/js/6b5d7254.4c379e61.js index d78ad9fb..9bd8d7c8 100644 --- a/assets/js/6b5d7254.1a2b0df8.js +++ b/assets/js/6b5d7254.4c379e61.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9548],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),s=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},c=function(e){var a=s(e.components);return r.createElement(p.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},d=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,p=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),g=s(n),d=t,y=g["".concat(p,".").concat(d)]||g[d]||m[d]||l;return n?r.createElement(y,i(i({ref:a},c),{},{components:n})):r.createElement(y,i({ref:a},c))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=d;var o={};for(var p in a)hasOwnProperty.call(a,p)&&(o[p]=a[p]);o.originalType=e,o[g]="string"==typeof e?e:t,i[1]=o;for(var s=2;s{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>o,toc:()=>s});var r=n(8168),t=(n(6540),n(5680));const l={id:"core_src.IHeapEdges",title:"Interface: IHeapEdges",sidebar_label:"IHeapEdges",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.IHeapEdges",id:"api/interfaces/core_src.IHeapEdges",title:"Interface: IHeapEdges",description:"A pseudo array containing all heap graph edges (references to heap objects",source:"@site/docs/api/interfaces/core_src.IHeapEdges.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapEdges",title:"Interface: IHeapEdges",sidebar_label:"IHeapEdges",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},next:{title:"IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation"}},p={},s=[{value:"Properties",id:"properties",level:2},{value:' length: number',id:"-length-number",level:3},{value:"Methods",id:"methods",level:2},{value:'forEach(callback)',id:"foreachcallback",level:3},{value:'get(index)',id:"getindex",level:3}],c={toc:s},g="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(g,(0,r.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"A pseudo array containing all heap graph edges (references to heap objects\nin heap). A JS heap could contain millions of references, so memlab uses\na pseudo array as the collection of all the heap edges. The pseudo\narray provides API to query and traverse all heap references."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," modifying this pseudo array is not recommended"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdges} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const edges: IHeapEdges = heap.edges;\n edges.length;\n edges.get(0);\n edges.forEach((edge, i) => {\n if (stopIteration) {\n return false;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-length-number"},(0,t.yg)("a",{id:"length",name:"length"})," ",(0,t.yg)("strong",{parentName:"h3"},"length"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of edges in heap graph (or JS references in heap\nsnapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1747"},"core/src/lib/Types.ts:1747"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"foreachcallback"},(0,t.yg)("a",{id:"foreach"}),(0,t.yg)("strong",{parentName:"h3"},"forEach"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"Iterate over all array elements and apply the callback\nto each element in ascending order of element index."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),", ",(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"void")," | the callback does not need to return any value, if the callback returns ",(0,t.yg)("inlineCode",{parentName:"li"},"false")," when iterating on element at index ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),", then all elements after ",(0,t.yg)("inlineCode",{parentName:"li"},"i")," won't be iterated."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1763"},"core/src/lib/Types.ts:1763"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getindex"},(0,t.yg)("a",{id:"get"}),(0,t.yg)("strong",{parentName:"h3"},"get"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"index"),")"),(0,t.yg)("p",null,"get an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge")," element at the specified index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the index of an element in the pseudo array, the index ranges from 0 to array length - 1. Notice that this is not the heap node id."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | When 0 <= ",(0,t.yg)("inlineCode",{parentName:"p"},"index")," < array.length, this API returns the element\nat the specified index, otherwise it returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1755"},"core/src/lib/Types.ts:1755"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9548],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),s=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},c=function(e){var a=s(e.components);return r.createElement(p.Provider,{value:a},e.children)},g="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},m=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,p=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),g=s(n),m=t,y=g["".concat(p,".").concat(m)]||g[m]||d[m]||l;return n?r.createElement(y,i(i({ref:a},c),{},{components:n})):r.createElement(y,i({ref:a},c))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=m;var o={};for(var p in a)hasOwnProperty.call(a,p)&&(o[p]=a[p]);o.originalType=e,o[g]="string"==typeof e?e:t,i[1]=o;for(var s=2;s{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>l,metadata:()=>o,toc:()=>s});var r=n(8168),t=(n(6540),n(5680));const l={id:"core_src.IHeapEdges",title:"Interface: IHeapEdges",sidebar_label:"IHeapEdges",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.IHeapEdges",id:"api/interfaces/core_src.IHeapEdges",title:"Interface: IHeapEdges",description:"A pseudo array containing all heap graph edges (references to heap objects",source:"@site/docs/api/interfaces/core_src.IHeapEdges.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapEdges",title:"Interface: IHeapEdges",sidebar_label:"IHeapEdges",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},next:{title:"IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation"}},p={},s=[{value:"Properties",id:"properties",level:2},{value:' length: number',id:"-length-number",level:3},{value:"Methods",id:"methods",level:2},{value:'forEach(callback)',id:"foreachcallback",level:3},{value:'get(index)',id:"getindex",level:3}],c={toc:s},g="wrapper";function d(e){let{components:a,...n}=e;return(0,t.yg)(g,(0,r.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"A pseudo array containing all heap graph edges (references to heap objects\nin heap). A JS heap could contain millions of references, so memlab uses\na pseudo array as the collection of all the heap edges. The pseudo\narray provides API to query and traverse all heap references."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," modifying this pseudo array is not recommended"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdges} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const edges: IHeapEdges = heap.edges;\n edges.length;\n edges.get(0);\n edges.forEach((edge, i) => {\n if (stopIteration) {\n return false;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-length-number"},(0,t.yg)("a",{id:"length",name:"length"})," ",(0,t.yg)("strong",{parentName:"h3"},"length"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of edges in heap graph (or JS references in heap\nsnapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1747"},"core/src/lib/Types.ts:1747"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"foreachcallback"},(0,t.yg)("a",{id:"foreach"}),(0,t.yg)("strong",{parentName:"h3"},"forEach"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"Iterate over all array elements and apply the callback\nto each element in ascending order of element index."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"edge"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),", ",(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"void")," | the callback does not need to return any value, if the callback returns ",(0,t.yg)("inlineCode",{parentName:"li"},"false")," when iterating on element at index ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),", then all elements after ",(0,t.yg)("inlineCode",{parentName:"li"},"i")," won't be iterated."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1763"},"core/src/lib/Types.ts:1763"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getindex"},(0,t.yg)("a",{id:"get"}),(0,t.yg)("strong",{parentName:"h3"},"get"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"index"),")"),(0,t.yg)("p",null,"get an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge")," element at the specified index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the index of an element in the pseudo array, the index ranges from 0 to array length - 1. Notice that this is not the heap node id."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapEdge")),">"," | When 0 <= ",(0,t.yg)("inlineCode",{parentName:"p"},"index")," < array.length, this API returns the element\nat the specified index, otherwise it returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1755"},"core/src/lib/Types.ts:1755"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/72eddb53.8615eb0d.js b/assets/js/72eddb53.1a366387.js similarity index 98% rename from assets/js/72eddb53.8615eb0d.js rename to assets/js/72eddb53.1a366387.js index 9a27b114..b6ed3475 100644 --- a/assets/js/72eddb53.8615eb0d.js +++ b/assets/js/72eddb53.1a366387.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1473],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>g});var t=n(6540);function l(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function s(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(l[n]=e[n]);return l}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},c=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},y="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},m=t.forwardRef((function(e,a){var n=e.components,l=e.mdxType,s=e.originalType,o=e.parentName,c=r(e,["components","mdxType","originalType","parentName"]),y=p(n),m=l,g=y["".concat(o,".").concat(m)]||y[m]||u[m]||s;return n?t.createElement(g,i(i({ref:a},c),{},{components:n})):t.createElement(g,i({ref:a},c))}));function g(e,a){var n=arguments,l=a&&a.mdxType;if("string"==typeof e||l){var s=n.length,i=new Array(s);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[y]="string"==typeof e?e:l,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>u,frontMatter:()=>s,metadata:()=>r,toc:()=>p});var t=n(8168),l=(n(6540),n(5680));const s={id:"heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",sidebar_label:"ObjectShallowAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectShallowAnalysis",id:"api/classes/heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",sidebar_label:"ObjectShallowAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},next:{title:"ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectShallowAnalysis()',id:"new-objectshallowanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getTopDuplicatedObjectInCount()',id:"gettopduplicatedobjectincount",level:3}],c={toc:p},y="wrapper";function u(e){let{components:a,...n}=e;return(0,l.yg)(y,(0,t.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,l.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,l.yg)("p",{parentName:"li"},"\u21b3 ",(0,l.yg)("strong",{parentName:"p"},(0,l.yg)("inlineCode",{parentName:"strong"},"ObjectShallowAnalysis"))))),(0,l.yg)("h2",{id:"constructors"},"Constructors"),(0,l.yg)("h3",{id:"new-objectshallowanalysis"},(0,l.yg)("a",{id:"new objectshallowanalysis"}),(0,l.yg)("strong",{parentName:"h3"},"new ObjectShallowAnalysis"),"()"),(0,l.yg)("h2",{id:"methods"},"Methods"),(0,l.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,l.yg)("a",{id:"analyzesnapshotfromfile"}),(0,l.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,l.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,l.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,l.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Parameters"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,l.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,l.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,l.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Example"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,l.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getcommandname"},(0,l.yg)("a",{id:"getcommandname"}),(0,l.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,l.yg)("p",null,"get CLI command name for this memory analysis;\nuse it with ",(0,l.yg)("inlineCode",{parentName:"p"},"memlab analyze ")," in CLI"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"p"},"string")," | command name")),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Source"),":"),(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectShallowAnalysis.ts#L65"},"heap-analysis/src/plugins/ObjectShallowAnalysis.ts:65"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"gettopduplicatedobjectincount"},(0,l.yg)("a",{id:"gettopduplicatedobjectincount"}),(0,l.yg)("strong",{parentName:"h3"},"getTopDuplicatedObjectInCount"),"()"),(0,l.yg)("p",null,"get the top duplicated object in terms of duplicated object count"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"p"},"ObjectRecord"),"[] | an array of the top-duplicated objects' information")),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Source"),":"),(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectShallowAnalysis.ts#L108"},"heap-analysis/src/plugins/ObjectShallowAnalysis.ts:108"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1473],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>g});var t=n(6540);function l(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function s(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(l[n]=e[n]);return l}(e,a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},c=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},y="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},m=t.forwardRef((function(e,a){var n=e.components,l=e.mdxType,s=e.originalType,o=e.parentName,c=r(e,["components","mdxType","originalType","parentName"]),y=p(n),m=l,g=y["".concat(o,".").concat(m)]||y[m]||u[m]||s;return n?t.createElement(g,i(i({ref:a},c),{},{components:n})):t.createElement(g,i({ref:a},c))}));function g(e,a){var n=arguments,l=a&&a.mdxType;if("string"==typeof e||l){var s=n.length,i=new Array(s);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[y]="string"==typeof e?e:l,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>u,frontMatter:()=>s,metadata:()=>r,toc:()=>p});var t=n(8168),l=(n(6540),n(5680));const s={id:"heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",sidebar_label:"ObjectShallowAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectShallowAnalysis",id:"api/classes/heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectShallowAnalysis",title:"Class: ObjectShallowAnalysis",sidebar_label:"ObjectShallowAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis"},next:{title:"ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectShallowAnalysis()',id:"new-objectshallowanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getTopDuplicatedObjectInCount()',id:"gettopduplicatedobjectincount",level:3}],c={toc:p},y="wrapper";function u(e){let{components:a,...n}=e;return(0,l.yg)(y,(0,t.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,l.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,l.yg)("p",{parentName:"li"},"\u21b3 ",(0,l.yg)("strong",{parentName:"p"},(0,l.yg)("inlineCode",{parentName:"strong"},"ObjectShallowAnalysis"))))),(0,l.yg)("h2",{id:"constructors"},"Constructors"),(0,l.yg)("h3",{id:"new-objectshallowanalysis"},(0,l.yg)("a",{id:"new objectshallowanalysis"}),(0,l.yg)("strong",{parentName:"h3"},"new ObjectShallowAnalysis"),"()"),(0,l.yg)("h2",{id:"methods"},"Methods"),(0,l.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,l.yg)("a",{id:"analyzesnapshotfromfile"}),(0,l.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,l.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,l.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,l.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Parameters"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,l.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,l.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,l.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,l.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Example"),":")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,l.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("strong",{parentName:"li"},"Source"),":",(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"getcommandname"},(0,l.yg)("a",{id:"getcommandname"}),(0,l.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,l.yg)("p",null,"get CLI command name for this memory analysis;\nuse it with ",(0,l.yg)("inlineCode",{parentName:"p"},"memlab analyze ")," in CLI"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"p"},"string")," | command name")),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Source"),":"),(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectShallowAnalysis.ts#L65"},"heap-analysis/src/plugins/ObjectShallowAnalysis.ts:65"))))),(0,l.yg)("hr",null),(0,l.yg)("h3",{id:"gettopduplicatedobjectincount"},(0,l.yg)("a",{id:"gettopduplicatedobjectincount"}),(0,l.yg)("strong",{parentName:"h3"},"getTopDuplicatedObjectInCount"),"()"),(0,l.yg)("p",null,"get the top duplicated object in terms of duplicated object count"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Returns"),": ",(0,l.yg)("inlineCode",{parentName:"p"},"ObjectRecord"),"[] | an array of the top-duplicated objects' information")),(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("p",{parentName:"li"},(0,l.yg)("strong",{parentName:"p"},"Source"),":"),(0,l.yg)("ul",{parentName:"li"},(0,l.yg)("li",{parentName:"ul"},(0,l.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectShallowAnalysis.ts#L108"},"heap-analysis/src/plugins/ObjectShallowAnalysis.ts:108"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/8b21a35a.7de6fb63.js b/assets/js/8b21a35a.4757b023.js similarity index 98% rename from assets/js/8b21a35a.7de6fb63.js rename to assets/js/8b21a35a.4757b023.js index 4651c884..de32012f 100644 --- a/assets/js/8b21a35a.7de6fb63.js +++ b/assets/js/8b21a35a.4757b023.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6640],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>u});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),p=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},m=function(e){var a=p(e.components);return t.createElement(s.Provider,{value:a},e.children)},g="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},y=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,m=o(e,["components","mdxType","originalType","parentName"]),g=p(n),y=r,u=g["".concat(s,".").concat(y)]||g[y]||d[y]||i;return n?t.createElement(u,l(l({ref:a},m),{},{components:n})):t.createElement(u,l({ref:a},m))}));function u(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var i=n.length,l=new Array(i);l[0]=y;var o={};for(var s in a)hasOwnProperty.call(a,s)&&(o[s]=a[s]);o.originalType=e,o[g]="string"==typeof e?e:r,l[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>d,frontMatter:()=>i,metadata:()=>o,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const i={id:"api_src",title:"Package: @memlab/api",sidebar_label:"api/src",sidebar_position:0,custom_edit_url:null},l=void 0,o={unversionedId:"api/modules/api_src",id:"api/modules/api_src",title:"Package: @memlab/api",description:"Enumerations",source:"@site/docs/api/modules/api_src.md",sourceDirName:"api/modules",slug:"/api/modules/api_src",permalink:"/memlab/docs/api/modules/api_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"api_src",title:"Package: @memlab/api",sidebar_label:"api/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"Table of contents",permalink:"/memlab/docs/api/"},next:{title:"core/src",permalink:"/memlab/docs/api/modules/core_src"}},s={},p=[{value:"Enumerations",id:"enumerations",level:2},{value:"Classes",id:"classes",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' RunOptions: Object',id:"-runoptions-object",level:3},{value:' RunResult: Object',id:"-runresult-object",level:3},{value:"Functions",id:"functions",level:2},{value:'analyze(runResult, heapAnalyzer, args?)',id:"analyzerunresult-heapanalyzer-args",level:3},{value:'findLeaks(runResult, options?)',id:"findleaksrunresult-options",level:3},{value:'findLeaksBySnapshotFilePaths(baselineSnapshot, targetSnapshot, finalSnapshot, options?)',id:"findleaksbysnapshotfilepathsbaselinesnapshot-targetsnapshot-finalsnapshot-options",level:3},{value:'run(options?)',id:"runoptions",level:3},{value:'takeSnapshots(options?)',id:"takesnapshotsoptions",level:3},{value:'warmupAndTakeSnapshots(options?)',id:"warmupandtakesnapshotsoptions",level:3}],m={toc:p},g="wrapper";function d(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("h2",{id:"enumerations"},"Enumerations"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"))),(0,r.yg)("h2",{id:"classes"},"Classes"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},"SnapshotResultReader"))),(0,r.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,r.yg)("h3",{id:"-runoptions-object"},(0,r.yg)("a",{id:"runoptions",name:"runoptions"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunOptions"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"Options for configuring browser interaction run, all fields are optional"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"chromiumBinary?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"if not specified, memlab will use the Chromium binary installed by Puppeteer. Use this option to specify a different binary if Puppeteer does not install the Chromium binary correctly (e.g., in a environtment Docker) or when you may want to use a different version of Chromium binary.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"consoleMode?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"specifying the terminal output mode, default is ",(0,r.yg)("inlineCode",{parentName:"td"},"default"),". For more details. please check out ",(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"))),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"cookiesFile?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"the absolute path of cookies file")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"evalInBrowserAfterInitLoad?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"AnyFunction")),(0,r.yg)("td",{parentName:"tr",align:"left"},"function to be evaluated in browser context after the web page initial load. Note that this function is defined in node.js context but it will be evaluated in browser context so the function should not use any closure variables outside of the browser context.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"scenario?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"IScenario")),(0,r.yg)("td",{parentName:"tr",align:"left"},"test scenario specifying how to interact with browser (for more details view ",(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/interfaces/core_src.IScenario"},"IScenario"),")")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"skipWarmup?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"boolean")),(0,r.yg)("td",{parentName:"tr",align:"left"},"skip the initial page loading warmup for the web application being tested")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"snapshotForEachStep?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"boolean")),(0,r.yg)("td",{parentName:"tr",align:"left"},"if true, take heap snapshot for each interaction step, by default this is false, which means memlab will decide which steps it will take heap snapshots")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"webWorker?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"Optional"),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"if this field is provided, it specifies the web worker as the target for heap analysis. For example ",(0,r.yg)("inlineCode",{parentName:"td"},"{webWorker: null}")," means analyzing the heap of the first web worker found. ",(0,r.yg)("inlineCode",{parentName:"td"},"{webWorker: 'workerTitle'}")," means analyzing the heap of the web worker with name: ",(0,r.yg)("inlineCode",{parentName:"td"},"'workerTitle'"),".")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"workDir?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"specify the working directory where you want memlab to dump heap snapshots and other meta data of the test run. If no working directory is provided, memlab will generate a random temp directory under the operating system's default directory for temporary files. Note: It's the caller's responsibility to make sure the specified working directory exists.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L47"},"api/src/API.ts:47"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-runresult-object"},(0,r.yg)("a",{id:"runresult",name:"runresult"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunResult"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"A data structure holding the result of the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#run"},"run")," API call."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"leaks")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"ISerializedInfo"),"[]"),(0,r.yg)("td",{parentName:"tr",align:"left"},"leak traces detected and clustered from the browser interaction")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"runResult")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"a utility for reading browser interaction results from disk")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L108"},"api/src/API.ts:108"))))),(0,r.yg)("h2",{id:"functions"},"Functions"),(0,r.yg)("h3",{id:"analyzerunresult-heapanalyzer-args"},(0,r.yg)("a",{id:"analyze"}),(0,r.yg)("strong",{parentName:"h3"},"analyze"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"runResult"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"heapAnalyzer"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"args?"),")"),(0,r.yg)("p",null,"This API analyzes heap snapshot(s) with a specified heap analysis.\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab analyze")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"runResult"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"default")," | return value of a browser interaction run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"heapAnalyzer"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," | instance of a heap analysis"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"args"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"ParsedArgs")," | other CLI arguments that needs to be passed to the heap analysis"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"void"),">"," | each analysis may have a different return type, please check out\nthe type definition or the documentation for the ",(0,r.yg)("inlineCode",{parentName:"li"},"process")," method of the\nanalysis class you are using for ",(0,r.yg)("inlineCode",{parentName:"li"},"heapAnalyzer"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {analyze, takeSnapshots, StringAnalysis} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario});\n const analysis = new StringAnalysis();\n await analyze(result, analysis);\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L328"},"api/src/API.ts:328"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"findleaksrunresult-options"},(0,r.yg)("a",{id:"findleaks"}),(0,r.yg)("strong",{parentName:"h3"},"findLeaks"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"runResult"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API finds memory leaks by analyzing heap snapshot(s).\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"runResult"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"default")," | return value of a browser interaction run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Object")," | configure memory leak detection run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.consoleMode?"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))," | specify the terminal output mode (see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"),")"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"ISerializedInfo"),"[]",">"," | leak traces detected and clustered from the browser interaction"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {findLeaks, takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario, consoleMode: 'SILENT'});\n const leaks = findLeaks(result, {consoleMode: 'CONTINUOUS_TEST'});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L256"},"api/src/API.ts:256"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"findleaksbysnapshotfilepathsbaselinesnapshot-targetsnapshot-finalsnapshot-options"},(0,r.yg)("a",{id:"findleaksbysnapshotfilepaths"}),(0,r.yg)("strong",{parentName:"h3"},"findLeaksBySnapshotFilePaths"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"baselineSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"targetSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"finalSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API finds memory leaks by analyzing specified heap snapshots.\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks")," with\nthe ",(0,r.yg)("inlineCode",{parentName:"p"},"--baseline"),", ",(0,r.yg)("inlineCode",{parentName:"p"},"--target"),", and ",(0,r.yg)("inlineCode",{parentName:"p"},"--final")," flags in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"baselineSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the baseline heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"targetSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the target heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"finalSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the final heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Object")," | optionally, you can specify a mode for heap analysis"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.consoleMode?"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))," | specify the terminal output mode (see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"),")"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.workDir?"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | specify a working directory (other than the default one)"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"ISerializedInfo"),"[]",">"," | leak traces detected and clustered from the browser interaction")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L284"},"api/src/API.ts:284"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"runoptions"},(0,r.yg)("a",{id:"run"}),(0,r.yg)("strong",{parentName:"h3"},"run"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API runs browser interaction and find memory leaks triggered in browser\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab run")," in CLI.\nThis is also equivalent to warm up, and call ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#takesnapshots"},"takeSnapshots"),"\nand ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runresult"},(0,r.yg)("inlineCode",{parentName:"a"},"RunResult")),">"," | memory leaks detected and a utility reading browser\ninteraction results from disk"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {run} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const {leaks} = await run({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L188"},"api/src/API.ts:188"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"takesnapshotsoptions"},(0,r.yg)("a",{id:"takesnapshots"}),(0,r.yg)("strong",{parentName:"h3"},"takeSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API runs E2E interaction and takes heap snapshots.\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab snapshot")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))," | configure browser interaction run"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader")),">"," | a utility reading browser interaction results from disk"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L221"},"api/src/API.ts:221"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"warmupandtakesnapshotsoptions"},(0,r.yg)("a",{id:"warmupandtakesnapshots"}),(0,r.yg)("strong",{parentName:"h3"},"warmupAndTakeSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API warms up web server, runs E2E interaction, and takes heap snapshots.\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab warmup-and-snapshot")," in CLI.\nThis is also equivalent to warm up and call ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#takesnapshots"},"takeSnapshots"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))," | configure browser interaction run"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader")),">"," | browser interaction results"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {warmupAndTakeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await warmupAndTakeSnapshots({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/API.ts#L151"},"api/src/API.ts:151"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[6640],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>u});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function i(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),p=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},m=function(e){var a=p(e.components);return t.createElement(s.Provider,{value:a},e.children)},g="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},y=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,m=o(e,["components","mdxType","originalType","parentName"]),g=p(n),y=r,u=g["".concat(s,".").concat(y)]||g[y]||d[y]||i;return n?t.createElement(u,l(l({ref:a},m),{},{components:n})):t.createElement(u,l({ref:a},m))}));function u(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var i=n.length,l=new Array(i);l[0]=y;var o={};for(var s in a)hasOwnProperty.call(a,s)&&(o[s]=a[s]);o.originalType=e,o[g]="string"==typeof e?e:r,l[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>d,frontMatter:()=>i,metadata:()=>o,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const i={id:"api_src",title:"Package: @memlab/api",sidebar_label:"api/src",sidebar_position:0,custom_edit_url:null},l=void 0,o={unversionedId:"api/modules/api_src",id:"api/modules/api_src",title:"Package: @memlab/api",description:"Enumerations",source:"@site/docs/api/modules/api_src.md",sourceDirName:"api/modules",slug:"/api/modules/api_src",permalink:"/memlab/docs/api/modules/api_src",draft:!1,editUrl:null,tags:[],version:"current",sidebarPosition:0,frontMatter:{id:"api_src",title:"Package: @memlab/api",sidebar_label:"api/src",sidebar_position:0,custom_edit_url:null},sidebar:"sidebar",previous:{title:"Table of contents",permalink:"/memlab/docs/api/"},next:{title:"core/src",permalink:"/memlab/docs/api/modules/core_src"}},s={},p=[{value:"Enumerations",id:"enumerations",level:2},{value:"Classes",id:"classes",level:2},{value:"Type Aliases",id:"type-aliases",level:2},{value:' RunOptions: Object',id:"-runoptions-object",level:3},{value:' RunResult: Object',id:"-runresult-object",level:3},{value:"Functions",id:"functions",level:2},{value:'analyze(runResult, heapAnalyzer, args?)',id:"analyzerunresult-heapanalyzer-args",level:3},{value:'findLeaks(runResult, options?)',id:"findleaksrunresult-options",level:3},{value:'findLeaksBySnapshotFilePaths(baselineSnapshot, targetSnapshot, finalSnapshot, options?)',id:"findleaksbysnapshotfilepathsbaselinesnapshot-targetsnapshot-finalsnapshot-options",level:3},{value:'run(options?)',id:"runoptions",level:3},{value:'takeSnapshots(options?)',id:"takesnapshotsoptions",level:3},{value:'warmupAndTakeSnapshots(options?)',id:"warmupandtakesnapshotsoptions",level:3}],m={toc:p},g="wrapper";function d(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("h2",{id:"enumerations"},"Enumerations"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"))),(0,r.yg)("h2",{id:"classes"},"Classes"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},"BrowserInteractionResultReader")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.SnapshotResultReader"},"SnapshotResultReader"))),(0,r.yg)("h2",{id:"type-aliases"},"Type Aliases"),(0,r.yg)("h3",{id:"-runoptions-object"},(0,r.yg)("a",{id:"runoptions",name:"runoptions"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunOptions"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"Options for configuring browser interaction run, all fields are optional"),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"chromiumBinary?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"if not specified, memlab will use the Chromium binary installed by Puppeteer. Use this option to specify a different binary if Puppeteer does not install the Chromium binary correctly (e.g., in a environtment Docker) or when you may want to use a different version of Chromium binary.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"consoleMode?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"specifying the terminal output mode, default is ",(0,r.yg)("inlineCode",{parentName:"td"},"default"),". For more details. please check out ",(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"))),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"cookiesFile?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"the absolute path of cookies file")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"evalInBrowserAfterInitLoad?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"AnyFunction")),(0,r.yg)("td",{parentName:"tr",align:"left"},"function to be evaluated in browser context after the web page initial load. Note that this function is defined in node.js context but it will be evaluated in browser context so the function should not use any closure variables outside of the browser context.")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"scenario?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"IScenario")),(0,r.yg)("td",{parentName:"tr",align:"left"},"test scenario specifying how to interact with browser (for more details view ",(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/interfaces/core_src.IScenario"},"IScenario"),")")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"skipWarmup?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"boolean")),(0,r.yg)("td",{parentName:"tr",align:"left"},"skip the initial page loading warmup for the web application being tested")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"snapshotForEachStep?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"boolean")),(0,r.yg)("td",{parentName:"tr",align:"left"},"if true, take heap snapshot for each interaction step, by default this is false, which means memlab will decide which steps it will take heap snapshots")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"webWorker?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"Optional"),"<",(0,r.yg)("inlineCode",{parentName:"td"},"string"),">"),(0,r.yg)("td",{parentName:"tr",align:"left"},"if this field is provided, it specifies the web worker as the target for heap analysis. For example ",(0,r.yg)("inlineCode",{parentName:"td"},"{webWorker: null}")," means analyzing the heap of the first web worker found. ",(0,r.yg)("inlineCode",{parentName:"td"},"{webWorker: 'workerTitle'}")," means analyzing the heap of the web worker with name: ",(0,r.yg)("inlineCode",{parentName:"td"},"'workerTitle'"),".")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"workDir?")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"string")),(0,r.yg)("td",{parentName:"tr",align:"left"},"specify the working directory where you want memlab to dump heap snapshots and other meta data of the test run. If no working directory is provided, memlab will generate a random temp directory under the operating system's default directory for temporary files. Note: It's the caller's responsibility to make sure the specified working directory exists.")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L47"},"api/src/API.ts:47"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-runresult-object"},(0,r.yg)("a",{id:"runresult",name:"runresult"})," ",(0,r.yg)("strong",{parentName:"h3"},"RunResult"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"Object")),(0,r.yg)("p",null,"A data structure holding the result of the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#run"},"run")," API call."),(0,r.yg)("table",null,(0,r.yg)("thead",{parentName:"table"},(0,r.yg)("tr",{parentName:"thead"},(0,r.yg)("th",{parentName:"tr",align:"left"},"Name"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Type"),(0,r.yg)("th",{parentName:"tr",align:"left"},"Description"))),(0,r.yg)("tbody",{parentName:"table"},(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"leaks")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"ISerializedInfo"),"[]"),(0,r.yg)("td",{parentName:"tr",align:"left"},"leak traces detected and clustered from the browser interaction")),(0,r.yg)("tr",{parentName:"tbody"},(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("inlineCode",{parentName:"td"},"runResult")),(0,r.yg)("td",{parentName:"tr",align:"left"},(0,r.yg)("a",{parentName:"td",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader"))),(0,r.yg)("td",{parentName:"tr",align:"left"},"a utility for reading browser interaction results from disk")))),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L108"},"api/src/API.ts:108"))))),(0,r.yg)("h2",{id:"functions"},"Functions"),(0,r.yg)("h3",{id:"analyzerunresult-heapanalyzer-args"},(0,r.yg)("a",{id:"analyze"}),(0,r.yg)("strong",{parentName:"h3"},"analyze"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"runResult"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"heapAnalyzer"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"args?"),")"),(0,r.yg)("p",null,"This API analyzes heap snapshot(s) with a specified heap analysis.\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab analyze")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"runResult"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"default")," | return value of a browser interaction run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"heapAnalyzer"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"BaseAnalysis")," | instance of a heap analysis"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"args"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"ParsedArgs")," | other CLI arguments that needs to be passed to the heap analysis"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"void"),">"," | each analysis may have a different return type, please check out\nthe type definition or the documentation for the ",(0,r.yg)("inlineCode",{parentName:"li"},"process")," method of the\nanalysis class you are using for ",(0,r.yg)("inlineCode",{parentName:"li"},"heapAnalyzer"),"."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {analyze, takeSnapshots, StringAnalysis} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario});\n const analysis = new StringAnalysis();\n await analyze(result, analysis);\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L328"},"api/src/API.ts:328"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"findleaksrunresult-options"},(0,r.yg)("a",{id:"findleaks"}),(0,r.yg)("strong",{parentName:"h3"},"findLeaks"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"runResult"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API finds memory leaks by analyzing heap snapshot(s).\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"runResult"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"default")," | return value of a browser interaction run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Object")," | configure memory leak detection run"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.consoleMode?"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))," | specify the terminal output mode (see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"),")"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"ISerializedInfo"),"[]",">"," | leak traces detected and clustered from the browser interaction"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {findLeaks, takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario, consoleMode: 'SILENT'});\n const leaks = findLeaks(result, {consoleMode: 'CONTINUOUS_TEST'});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L256"},"api/src/API.ts:256"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"findleaksbysnapshotfilepathsbaselinesnapshot-targetsnapshot-finalsnapshot-options"},(0,r.yg)("a",{id:"findleaksbysnapshotfilepaths"}),(0,r.yg)("strong",{parentName:"h3"},"findLeaksBySnapshotFilePaths"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"baselineSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"targetSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"finalSnapshot"),", ",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API finds memory leaks by analyzing specified heap snapshots.\nThis is equivalent to ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab find-leaks")," with\nthe ",(0,r.yg)("inlineCode",{parentName:"p"},"--baseline"),", ",(0,r.yg)("inlineCode",{parentName:"p"},"--target"),", and ",(0,r.yg)("inlineCode",{parentName:"p"},"--final")," flags in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"baselineSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the baseline heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"targetSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the target heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"finalSnapshot"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the file path of the final heap snapshot"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Object")," | optionally, you can specify a mode for heap analysis"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.consoleMode?"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},(0,r.yg)("inlineCode",{parentName:"a"},"ConsoleMode"))," | specify the terminal output mode (see ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/enums/api_src.ConsoleMode"},"ConsoleMode"),")"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options.workDir?"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | specify a working directory (other than the default one)"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Promise"),"<",(0,r.yg)("inlineCode",{parentName:"p"},"ISerializedInfo"),"[]",">"," | leak traces detected and clustered from the browser interaction")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Source"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L284"},"api/src/API.ts:284"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"runoptions"},(0,r.yg)("a",{id:"run"}),(0,r.yg)("strong",{parentName:"h3"},"run"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API runs browser interaction and find memory leaks triggered in browser\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab run")," in CLI.\nThis is also equivalent to warm up, and call ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#takesnapshots"},"takeSnapshots"),"\nand ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runresult"},(0,r.yg)("inlineCode",{parentName:"a"},"RunResult")),">"," | memory leaks detected and a utility reading browser\ninteraction results from disk"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {run} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const {leaks} = await run({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L188"},"api/src/API.ts:188"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"takesnapshotsoptions"},(0,r.yg)("a",{id:"takesnapshots"}),(0,r.yg)("strong",{parentName:"h3"},"takeSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API runs E2E interaction and takes heap snapshots.\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab snapshot")," in CLI."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))," | configure browser interaction run"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader")),">"," | a utility reading browser interaction results from disk"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await takeSnapshots({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L221"},"api/src/API.ts:221"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"warmupandtakesnapshotsoptions"},(0,r.yg)("a",{id:"warmupandtakesnapshots"}),(0,r.yg)("strong",{parentName:"h3"},"warmupAndTakeSnapshots"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,r.yg)("p",null,"This API warms up web server, runs E2E interaction, and takes heap snapshots.\nThis is equivalent to running ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab warmup-and-snapshot")," in CLI.\nThis is also equivalent to warm up and call ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#takesnapshots"},"takeSnapshots"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/api_src#runoptions"},(0,r.yg)("inlineCode",{parentName:"a"},"RunOptions"))," | configure browser interaction run"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,r.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader")),">"," | browser interaction results"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"const {warmupAndTakeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n };\n const result = await warmupAndTakeSnapshots({scenario});\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/API.ts#L151"},"api/src/API.ts:151"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/95206942.2869ba06.js b/assets/js/95206942.0c281ce3.js similarity index 98% rename from assets/js/95206942.2869ba06.js rename to assets/js/95206942.0c281ce3.js index 9af9e44b..b5f8450b 100644 --- a/assets/js/95206942.2869ba06.js +++ b/assets/js/95206942.0c281ce3.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2522],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>u});var l=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function t(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,l)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=l.createContext({}),p=function(e){var a=l.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return l.createElement(o.Provider,{value:a},e.children)},c="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return l.createElement(l.Fragment,{},a)}},m=l.forwardRef((function(e,a){var n=e.components,s=e.mdxType,t=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),m=s,u=c["".concat(o,".").concat(m)]||c[m]||g[m]||t;return n?l.createElement(u,i(i({ref:a},y),{},{components:n})):l.createElement(u,i({ref:a},y))}));function u(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var t=n.length,i=new Array(t);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>g,frontMatter:()=>t,metadata:()=>r,toc:()=>p});var l=n(8168),s=(n(6540),n(5680));const t={id:"heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",sidebar_label:"CollectionsHoldingStaleAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",id:"api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",sidebar_label:"CollectionsHoldingStaleAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},next:{title:"DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new CollectionsHoldingStaleAnalysis()',id:"new-collectionsholdingstaleanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function g(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,l.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"CollectionsHoldingStaleAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-collectionsholdingstaleanalysis"},(0,s.yg)("a",{id:"new collectionsholdingstaleanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new CollectionsHoldingStaleAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/CollectionsHoldingStaleAnalysis.ts#L67"},"heap-analysis/src/plugins/CollectionsHoldingStaleAnalysis.ts:67"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[2522],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>u});var l=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function t(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);a&&(l=l.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,l)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);for(l=0;l=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=l.createContext({}),p=function(e){var a=l.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return l.createElement(o.Provider,{value:a},e.children)},c="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return l.createElement(l.Fragment,{},a)}},m=l.forwardRef((function(e,a){var n=e.components,s=e.mdxType,t=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),m=s,u=c["".concat(o,".").concat(m)]||c[m]||g[m]||t;return n?l.createElement(u,i(i({ref:a},y),{},{components:n})):l.createElement(u,i({ref:a},y))}));function u(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var t=n.length,i=new Array(t);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>g,frontMatter:()=>t,metadata:()=>r,toc:()=>p});var l=n(8168),s=(n(6540),n(5680));const t={id:"heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",sidebar_label:"CollectionsHoldingStaleAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",id:"api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.CollectionsHoldingStaleAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.CollectionsHoldingStaleAnalysis",title:"Class: CollectionsHoldingStaleAnalysis",sidebar_label:"CollectionsHoldingStaleAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"BaseAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},next:{title:"DetachedDOMElementAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.DetachedDOMElementAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new CollectionsHoldingStaleAnalysis()',id:"new-collectionsholdingstaleanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function g(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,l.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"CollectionsHoldingStaleAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-collectionsholdingstaleanalysis"},(0,s.yg)("a",{id:"new collectionsholdingstaleanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new CollectionsHoldingStaleAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/CollectionsHoldingStaleAnalysis.ts#L67"},"heap-analysis/src/plugins/CollectionsHoldingStaleAnalysis.ts:67"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/95f47cf5.7e757fda.js b/assets/js/95f47cf5.53ed909a.js similarity index 98% rename from assets/js/95f47cf5.7e757fda.js rename to assets/js/95f47cf5.53ed909a.js index 70648121..e4cfd1b8 100644 --- a/assets/js/95f47cf5.7e757fda.js +++ b/assets/js/95f47cf5.53ed909a.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[7130],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),p=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return s.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},u=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=t,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||l;return n?s.createElement(g,i(i({ref:a},y),{},{components:n})):s.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:t,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",sidebar_label:"ObjectShapeAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectShapeAnalysis",id:"api/classes/heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",sidebar_label:"ObjectShapeAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},next:{title:"ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectShapeAnalysis()',id:"new-objectshapeanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(c,(0,s.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"ObjectShapeAnalysis"))))),(0,t.yg)("h2",{id:"constructors"},"Constructors"),(0,t.yg)("h3",{id:"new-objectshapeanalysis"},(0,t.yg)("a",{id:"new objectshapeanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"new ObjectShapeAnalysis"),"()"),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,t.yg)("a",{id:"analyzesnapshotfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,t.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getcommandname"},(0,t.yg)("a",{id:"getcommandname"}),(0,t.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,t.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,t.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectShapeAnalysis.ts#L28"},"heap-analysis/src/plugins/ObjectShapeAnalysis.ts:28"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[7130],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var s=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);a&&(s=s.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,s)}return n}function i(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var o=s.createContext({}),p=function(e){var a=s.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return s.createElement(o.Provider,{value:a},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return s.createElement(s.Fragment,{},a)}},u=s.forwardRef((function(e,a){var n=e.components,t=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),u=t,g=c["".concat(o,".").concat(u)]||c[u]||m[u]||l;return n?s.createElement(g,i(i({ref:a},y),{},{components:n})):s.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var l=n.length,i=new Array(l);i[0]=u;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:t,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var s=n(8168),t=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",sidebar_label:"ObjectShapeAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectShapeAnalysis",id:"api/classes/heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectShapeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShapeAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectShapeAnalysis",title:"Class: ObjectShapeAnalysis",sidebar_label:"ObjectShapeAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"},next:{title:"ObjectSizeAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectSizeAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectShapeAnalysis()',id:"new-objectshapeanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(c,(0,s.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,t.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"ObjectShapeAnalysis"))))),(0,t.yg)("h2",{id:"constructors"},"Constructors"),(0,t.yg)("h3",{id:"new-objectshapeanalysis"},(0,t.yg)("a",{id:"new objectshapeanalysis"}),(0,t.yg)("strong",{parentName:"h3"},"new ObjectShapeAnalysis"),"()"),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,t.yg)("a",{id:"analyzesnapshotfromfile"}),(0,t.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,t.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,t.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,t.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,t.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,t.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Example"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,t.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getcommandname"},(0,t.yg)("a",{id:"getcommandname"}),(0,t.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,t.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,t.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,t.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectShapeAnalysis.ts#L28"},"heap-analysis/src/plugins/ObjectShapeAnalysis.ts:28"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/98c9c166.cac6eee1.js b/assets/js/98c9c166.ebb42bed.js similarity index 92% rename from assets/js/98c9c166.cac6eee1.js rename to assets/js/98c9c166.ebb42bed.js index 7bd2a23a..1f1470f4 100644 --- a/assets/js/98c9c166.cac6eee1.js +++ b/assets/js/98c9c166.ebb42bed.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[984],{5680:(e,n,a)=>{a.d(n,{xA:()=>g,yg:()=>y});var r=a(6540);function t(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function o(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,r)}return a}function i(e){for(var n=1;n=0||(t[a]=e[a]);return t}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(t[a]=e[a])}return t}var p=r.createContext({}),s=function(e){var n=r.useContext(p),a=n;return e&&(a="function"==typeof e?e(n):i(i({},n),e)),a},g=function(e){var n=s(e.components);return r.createElement(p.Provider,{value:n},e.children)},c="mdxType",d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},m=r.forwardRef((function(e,n){var a=e.components,t=e.mdxType,o=e.originalType,p=e.parentName,g=l(e,["components","mdxType","originalType","parentName"]),c=s(a),m=t,y=c["".concat(p,".").concat(m)]||c[m]||d[m]||o;return a?r.createElement(y,i(i({ref:n},g),{},{components:a})):r.createElement(y,i({ref:n},g))}));function y(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var o=a.length,i=new Array(o);i[0]=m;var l={};for(var p in n)hasOwnProperty.call(n,p)&&(l[p]=n[p]);l.originalType=e,l[c]="string"==typeof e?e:t,i[1]=l;for(var s=2;s{a.r(n),a.d(n,{assets:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>o,metadata:()=>l,toc:()=>s});var r=a(8168),t=(a(6540),a(5680));const o={id:"core_src.IHeapEdge",title:"Interface: IHeapEdge",sidebar_label:"IHeapEdge",custom_edit_url:null},i=void 0,l={unversionedId:"api/interfaces/core_src.IHeapEdge",id:"api/interfaces/core_src.IHeapEdge",title:"Interface: IHeapEdge",description:"An IHeapEdge instance represents a JS reference in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapEdge.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapEdge",title:"Interface: IHeapEdge",sidebar_label:"IHeapEdge",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},next:{title:"IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges"}},p={},s=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' edgeIndex: number',id:"-edgeindex-number",level:3},{value:' fromNode: IHeapNode',id:"-fromnode-iheapnode",level:3},{value:' is_index: boolean',id:"-is_index-boolean",level:3},{value:' name_or_index: string | number',id:"-name_or_index-string--number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' toNode: IHeapNode',id:"-tonode-iheapnode",level:3},{value:' to_node: number',id:"-to_node-number",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3}],g={toc:s},c="wrapper";function d(e){let{components:n,...a}=e;return(0,t.yg)(c,(0,r.A)({},g,a,{components:n,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdge")," instance represents a JS reference in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdge")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each edge (JS reference in heap)\n heap.edges.forEach((edge: IHeapEdge, i: number) => {\n // use the heap edge APIs here\n const nameOrIndex = edge.name_or_index;\n // ...\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdgeBasic")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapEdge"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-edgeindex-number"},(0,t.yg)("a",{id:"edgeindex",name:"edgeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"edgeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this JS reference inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"edge.snapshot.edges")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1668"},"core/src/lib/Types.ts:1668"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-fromnode-iheapnode"},(0,t.yg)("a",{id:"fromnode",name:"fromnode"})," ",(0,t.yg)("strong",{parentName:"h3"},"fromNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",null,"returns an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," instance representing the hosting\nJS heap object where this reference starts"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1689"},"core/src/lib/Types.ts:1689"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_index-boolean"},(0,t.yg)("a",{id:"is\\_index",name:"is\\_index"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","index"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"if ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", means this is a reference to an array element\nor internal table element (",(0,t.yg)("inlineCode",{parentName:"p"},"edge.name_or_index")," will return a number),\notherwise this is a reference with a string name (",(0,t.yg)("inlineCode",{parentName:"p"},"edge.name_or_index"),"\nwill return a string)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1675"},"core/src/lib/Types.ts:1675"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name_or_index-string--number"},(0,t.yg)("a",{id:"name\\_or\\_index",name:"name\\_or\\_index"})," ",(0,t.yg)("strong",{parentName:"h3"},"name","_","or","_","index"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"name of the JS reference. If this is a reference to an array element\nor internal table element, it is an numeric index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1624"},"core/src/lib/Types.ts:1624"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this JS reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1664"},"core/src/lib/Types.ts:1664"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-tonode-iheapnode"},(0,t.yg)("a",{id:"tonode",name:"tonode"})," ",(0,t.yg)("strong",{parentName:"h3"},"toNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",null,"returns an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," instance representing the JS heap object\npointed to by this reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1684"},"core/src/lib/Types.ts:1684"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-to_node-number"},(0,t.yg)("a",{id:"to\\_node",name:"to\\_node"})," ",(0,t.yg)("strong",{parentName:"h3"},"to","_","node"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"the index of the JS heap object pointed to by this reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1679"},"core/src/lib/Types.ts:1679"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"type of the JS reference, all types:\n",(0,t.yg)("inlineCode",{parentName:"p"},"context"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"element"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"property"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"internal"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"shortcut"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"weak")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1629"},"core/src/lib/Types.ts:1629"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1697"},"core/src/lib/Types.ts:1697"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1710"},"core/src/lib/Types.ts:1710"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[984],{5680:(e,n,a)=>{a.d(n,{xA:()=>g,yg:()=>y});var r=a(6540);function t(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function o(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,r)}return a}function i(e){for(var n=1;n=0||(t[a]=e[a]);return t}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(t[a]=e[a])}return t}var p=r.createContext({}),s=function(e){var n=r.useContext(p),a=n;return e&&(a="function"==typeof e?e(n):i(i({},n),e)),a},g=function(e){var n=s(e.components);return r.createElement(p.Provider,{value:n},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},m=r.forwardRef((function(e,n){var a=e.components,t=e.mdxType,o=e.originalType,p=e.parentName,g=l(e,["components","mdxType","originalType","parentName"]),d=s(a),m=t,y=d["".concat(p,".").concat(m)]||d[m]||c[m]||o;return a?r.createElement(y,i(i({ref:n},g),{},{components:a})):r.createElement(y,i({ref:n},g))}));function y(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var o=a.length,i=new Array(o);i[0]=m;var l={};for(var p in n)hasOwnProperty.call(n,p)&&(l[p]=n[p]);l.originalType=e,l[d]="string"==typeof e?e:t,i[1]=l;for(var s=2;s{a.r(n),a.d(n,{assets:()=>p,contentTitle:()=>i,default:()=>c,frontMatter:()=>o,metadata:()=>l,toc:()=>s});var r=a(8168),t=(a(6540),a(5680));const o={id:"core_src.IHeapEdge",title:"Interface: IHeapEdge",sidebar_label:"IHeapEdge",custom_edit_url:null},i=void 0,l={unversionedId:"api/interfaces/core_src.IHeapEdge",id:"api/interfaces/core_src.IHeapEdge",title:"Interface: IHeapEdge",description:"An IHeapEdge instance represents a JS reference in a heap snapshot.",source:"@site/docs/api/interfaces/core_src.IHeapEdge.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapEdge",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdge",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapEdge",title:"Interface: IHeapEdge",sidebar_label:"IHeapEdge",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IBrowserInfo",permalink:"/memlab/docs/api/interfaces/core_src.IBrowserInfo"},next:{title:"IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges"}},p={},s=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Properties",id:"properties",level:2},{value:' edgeIndex: number',id:"-edgeindex-number",level:3},{value:' fromNode: IHeapNode',id:"-fromnode-iheapnode",level:3},{value:' is_index: boolean',id:"-is_index-boolean",level:3},{value:' name_or_index: string | number',id:"-name_or_index-string--number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:' toNode: IHeapNode',id:"-tonode-iheapnode",level:3},{value:' to_node: number',id:"-to_node-number",level:3},{value:' type: string',id:"-type-string",level:3},{value:"Methods",id:"methods",level:2},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3}],g={toc:s},d="wrapper";function c(e){let{components:n,...a}=e;return(0,t.yg)(d,(0,r.A)({},g,a,{components:n,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"An ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdge")," instance represents a JS reference in a heap snapshot.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdge")," instance"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each edge (JS reference in heap)\n heap.edges.forEach((edge: IHeapEdge, i: number) => {\n // use the heap edge APIs here\n const nameOrIndex = edge.name_or_index;\n // ...\n });\n})();\n")),(0,t.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("inlineCode",{parentName:"p"},"IHeapEdgeBasic")),(0,t.yg)("p",{parentName:"li"},"\u21b3 ",(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"IHeapEdge"))))),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-edgeindex-number"},(0,t.yg)("a",{id:"edgeindex",name:"edgeindex"})," ",(0,t.yg)("strong",{parentName:"h3"},"edgeIndex"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"index of this JS reference inside the ",(0,t.yg)("inlineCode",{parentName:"p"},"edge.snapshot.edges")," pseudo array"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1668"},"core/src/lib/Types.ts:1668"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-fromnode-iheapnode"},(0,t.yg)("a",{id:"fromnode",name:"fromnode"})," ",(0,t.yg)("strong",{parentName:"h3"},"fromNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",null,"returns an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," instance representing the hosting\nJS heap object where this reference starts"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1689"},"core/src/lib/Types.ts:1689"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-is_index-boolean"},(0,t.yg)("a",{id:"is\\_index",name:"is\\_index"})," ",(0,t.yg)("strong",{parentName:"h3"},"is","_","index"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"boolean")),(0,t.yg)("p",null,"if ",(0,t.yg)("inlineCode",{parentName:"p"},"true"),", means this is a reference to an array element\nor internal table element (",(0,t.yg)("inlineCode",{parentName:"p"},"edge.name_or_index")," will return a number),\notherwise this is a reference with a string name (",(0,t.yg)("inlineCode",{parentName:"p"},"edge.name_or_index"),"\nwill return a string)"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1675"},"core/src/lib/Types.ts:1675"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-name_or_index-string--number"},(0,t.yg)("a",{id:"name\\_or\\_index",name:"name\\_or\\_index"})," ",(0,t.yg)("strong",{parentName:"h3"},"name","_","or","_","index"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"name of the JS reference. If this is a reference to an array element\nor internal table element, it is an numeric index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1624"},"core/src/lib/Types.ts:1624"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,t.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,t.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,t.yg)("p",null,"get the ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this JS reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1664"},"core/src/lib/Types.ts:1664"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-tonode-iheapnode"},(0,t.yg)("a",{id:"tonode",name:"tonode"})," ",(0,t.yg)("strong",{parentName:"h3"},"toNode"),": ",(0,t.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode"))),(0,t.yg)("p",null,"returns an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," instance representing the JS heap object\npointed to by this reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1684"},"core/src/lib/Types.ts:1684"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-to_node-number"},(0,t.yg)("a",{id:"to\\_node",name:"to\\_node"})," ",(0,t.yg)("strong",{parentName:"h3"},"to","_","node"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"the index of the JS heap object pointed to by this reference"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1679"},"core/src/lib/Types.ts:1679"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"-type-string"},(0,t.yg)("a",{id:"type",name:"type"})," ",(0,t.yg)("strong",{parentName:"h3"},"type"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"string")),(0,t.yg)("p",null,"type of the JS reference, all types:\n",(0,t.yg)("inlineCode",{parentName:"p"},"context"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"element"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"property"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"internal"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"hidden"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"shortcut"),", ",(0,t.yg)("inlineCode",{parentName:"p"},"weak")),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1629"},"core/src/lib/Types.ts:1629"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"getjsonifyableobject"},(0,t.yg)("a",{id:"getjsonifyableobject"}),(0,t.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,t.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1697"},"core/src/lib/Types.ts:1697"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"tojsonstringargs"},(0,t.yg)("a",{id:"tojsonstring"}),(0,t.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,t.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,t.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,t.yg)("p",null,"Note: Please be aware that using ",(0,t.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,t.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"string")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1710"},"core/src/lib/Types.ts:1710"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/b53f1d78.2c145d5a.js b/assets/js/b53f1d78.11c43043.js similarity index 95% rename from assets/js/b53f1d78.2c145d5a.js rename to assets/js/b53f1d78.11c43043.js index 81080cd7..82361e92 100644 --- a/assets/js/b53f1d78.2c145d5a.js +++ b/assets/js/b53f1d78.11c43043.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[3925],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),p=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},c=function(e){var a=p(e.components);return t.createElement(s.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),g=p(n),u=r,y=g["".concat(s,".").concat(u)]||g[u]||m[u]||o;return n?t.createElement(y,l(l({ref:a},c),{},{components:n})):t.createElement(y,l({ref:a},c))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=u;var i={};for(var s in a)hasOwnProperty.call(a,s)&&(i[s]=a[s]);i.originalType=e,i[g]="string"==typeof e?e:r,l[1]=i;for(var p=2;p{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>m,frontMatter:()=>o,metadata:()=>i,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const o={id:"core_src.IHeapLocation",title:"Interface: IHeapLocation",sidebar_label:"IHeapLocation",custom_edit_url:null},l=void 0,i={unversionedId:"api/interfaces/core_src.IHeapLocation",id:"api/interfaces/core_src.IHeapLocation",title:"Interface: IHeapLocation",description:"An IHeapLocation instance contains a source location information",source:"@site/docs/api/interfaces/core_src.IHeapLocation.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapLocation",title:"Interface: IHeapLocation",sidebar_label:"IHeapLocation",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},next:{title:"IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode"}},s={},p=[{value:"Properties",id:"properties",level:2},{value:' column: number',id:"-column-number",level:3},{value:' line: number',id:"-line-number",level:3},{value:' node: Nullable<IHeapNode>',id:"-node-nullableiheapnode",level:3},{value:' script_id: number',id:"-script_id-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:"Methods",id:"methods",level:2},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3}],c={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"An ",(0,r.yg)("inlineCode",{parentName:"p"},"IHeapLocation")," instance contains a source location information\nassociated with a JS heap object.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},(0,r.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,r.yg)("inlineCode",{parentName:"p"},"IHeapLocation")," instance"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode, IHeapLocation} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n const location: Nullable = node.location;\n if (location) {\n // use the location API here\n location.line;\n // ...\n }\n });\n})();\n")),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-column-number"},(0,r.yg)("a",{id:"column",name:"column"})," ",(0,r.yg)("strong",{parentName:"h3"},"column"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the column number"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1594"},"core/src/lib/Types.ts:1594"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-line-number"},(0,r.yg)("a",{id:"line",name:"line"})," ",(0,r.yg)("strong",{parentName:"h3"},"line"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the line number"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1590"},"core/src/lib/Types.ts:1590"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-node-nullableiheapnode"},(0,r.yg)("a",{id:"node",name:"node"})," ",(0,r.yg)("strong",{parentName:"h3"},"node"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,r.yg)("p",null,"get the heap object this location this location represents"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1582"},"core/src/lib/Types.ts:1582"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-script_id-number"},(0,r.yg)("a",{id:"script\\_id",name:"script\\_id"})," ",(0,r.yg)("strong",{parentName:"h3"},"script","_","id"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the script ID of the source file"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1586"},"core/src/lib/Types.ts:1586"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,r.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,r.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,r.yg)("p",null,"get the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this location instance"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1578"},"core/src/lib/Types.ts:1578"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getjsonifyableobject"},(0,r.yg)("a",{id:"getjsonifyableobject"}),(0,r.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,r.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,r.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1602"},"core/src/lib/Types.ts:1602"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"tojsonstringargs"},(0,r.yg)("a",{id:"tojsonstring"}),(0,r.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,r.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,r.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,r.yg)("p",null,"Note: Please be aware that using ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,r.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1615"},"core/src/lib/Types.ts:1615"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[3925],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),p=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},c=function(e){var a=p(e.components);return t.createElement(s.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},u=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),g=p(n),u=r,y=g["".concat(s,".").concat(u)]||g[u]||m[u]||o;return n?t.createElement(y,l(l({ref:a},c),{},{components:n})):t.createElement(y,l({ref:a},c))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=u;var i={};for(var s in a)hasOwnProperty.call(a,s)&&(i[s]=a[s]);i.originalType=e,i[g]="string"==typeof e?e:r,l[1]=i;for(var p=2;p{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>m,frontMatter:()=>o,metadata:()=>i,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const o={id:"core_src.IHeapLocation",title:"Interface: IHeapLocation",sidebar_label:"IHeapLocation",custom_edit_url:null},l=void 0,i={unversionedId:"api/interfaces/core_src.IHeapLocation",id:"api/interfaces/core_src.IHeapLocation",title:"Interface: IHeapLocation",description:"An IHeapLocation instance contains a source location information",source:"@site/docs/api/interfaces/core_src.IHeapLocation.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapLocation",permalink:"/memlab/docs/api/interfaces/core_src.IHeapLocation",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapLocation",title:"Interface: IHeapLocation",sidebar_label:"IHeapLocation",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapEdges",permalink:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},next:{title:"IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode"}},s={},p=[{value:"Properties",id:"properties",level:2},{value:' column: number',id:"-column-number",level:3},{value:' line: number',id:"-line-number",level:3},{value:' node: Nullable<IHeapNode>',id:"-node-nullableiheapnode",level:3},{value:' script_id: number',id:"-script_id-number",level:3},{value:' snapshot: IHeapSnapshot',id:"-snapshot-iheapsnapshot",level:3},{value:"Methods",id:"methods",level:2},{value:'getJSONifyableObject()',id:"getjsonifyableobject",level:3},{value:'toJSONString(...args)',id:"tojsonstringargs",level:3}],c={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"An ",(0,r.yg)("inlineCode",{parentName:"p"},"IHeapLocation")," instance contains a source location information\nassociated with a JS heap object.\nA heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},(0,r.yg)("inlineCode",{parentName:"strong"},"readonly"))," it is not recommended to modify any ",(0,r.yg)("inlineCode",{parentName:"p"},"IHeapLocation")," instance"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),": V8 or hermes heap snapshot can be parsed by the\n",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#getfullheapfromfile"},"getFullHeapFromFile")," API.")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode, IHeapLocation} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // iterate over each node (heap object)\n heap.nodes.forEach((node: IHeapNode, i: number) => {\n const location: Nullable = node.location;\n if (location) {\n // use the location API here\n location.line;\n // ...\n }\n });\n})();\n")),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-column-number"},(0,r.yg)("a",{id:"column",name:"column"})," ",(0,r.yg)("strong",{parentName:"h3"},"column"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the column number"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1594"},"core/src/lib/Types.ts:1594"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-line-number"},(0,r.yg)("a",{id:"line",name:"line"})," ",(0,r.yg)("strong",{parentName:"h3"},"line"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the line number"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1590"},"core/src/lib/Types.ts:1590"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-node-nullableiheapnode"},(0,r.yg)("a",{id:"node",name:"node"})," ",(0,r.yg)("strong",{parentName:"h3"},"node"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"),(0,r.yg)("p",null,"get the heap object this location this location represents"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1582"},"core/src/lib/Types.ts:1582"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-script_id-number"},(0,r.yg)("a",{id:"script\\_id",name:"script\\_id"})," ",(0,r.yg)("strong",{parentName:"h3"},"script","_","id"),": ",(0,r.yg)("inlineCode",{parentName:"h3"},"number")),(0,r.yg)("p",null,"get the script ID of the source file"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1586"},"core/src/lib/Types.ts:1586"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-snapshot-iheapsnapshot"},(0,r.yg)("a",{id:"snapshot",name:"snapshot"})," ",(0,r.yg)("strong",{parentName:"h3"},"snapshot"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapSnapshot"))),(0,r.yg)("p",null,"get the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," containing this location instance"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1578"},"core/src/lib/Types.ts:1578"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getjsonifyableobject"},(0,r.yg)("a",{id:"getjsonifyableobject"}),(0,r.yg)("strong",{parentName:"h3"},"getJSONifyableObject"),"()"),(0,r.yg)("p",null,"convert to a concise readable object that can be used for serialization\n(like calling ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,r.yg)("p",null,"This API does not contain all the information\ncaptured by the hosting object."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"AnyRecord")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1602"},"core/src/lib/Types.ts:1602"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"tojsonstringargs"},(0,r.yg)("a",{id:"tojsonstring"}),(0,r.yg)("strong",{parentName:"h3"},"toJSONString"),"(...",(0,r.yg)("inlineCode",{parentName:"h3"},"args"),")"),(0,r.yg)("p",null,"convert to a concise readable string output\n(like calling ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)"),")."),(0,r.yg)("p",null,"Note: Please be aware that using ",(0,r.yg)("inlineCode",{parentName:"p"},"JSON.stringify(node, ...args)")," is\nnot recommended as it will generate a JSON representation of the host\nobject that is too large to be easily readable due to its connections\nto other parts of the data structures within the heap snapshot."),(0,r.yg)("p",null,"This API does not completely serialize all the information\ncaptured by the hosting object."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"...args"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"any"),"[]"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1615"},"core/src/lib/Types.ts:1615"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/c90dd339.bc9326e4.js b/assets/js/c90dd339.f50c64ca.js similarity index 97% rename from assets/js/c90dd339.bc9326e4.js rename to assets/js/c90dd339.f50c64ca.js index 03058d6a..cc7d1399 100644 --- a/assets/js/c90dd339.bc9326e4.js +++ b/assets/js/c90dd339.f50c64ca.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1456],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),i=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},m=function(e){var a=i(e.components);return t.createElement(s.Provider,{value:a},e.children)},c="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},d=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),c=i(n),d=r,y=c["".concat(s,".").concat(d)]||c[d]||g[d]||o;return n?t.createElement(y,l(l({ref:a},m),{},{components:n})):t.createElement(y,l({ref:a},m))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=d;var p={};for(var s in a)hasOwnProperty.call(a,s)&&(p[s]=a[s]);p.originalType=e,p[c]="string"==typeof e?e:r,l[1]=p;for(var i=2;i{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>g,frontMatter:()=>o,metadata:()=>p,toc:()=>i});var t=n(8168),r=(n(6540),n(5680));const o={id:"core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",sidebar_label:"IHeapSnapshot",custom_edit_url:null},l=void 0,p={unversionedId:"api/interfaces/core_src.IHeapSnapshot",id:"api/interfaces/core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",description:"A heap snapshot is generally a graph where graph nodes are JS heap objects",source:"@site/docs/api/interfaces/core_src.IHeapSnapshot.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",sidebar_label:"IHeapSnapshot",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},next:{title:"IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"}},s={},i=[{value:"Properties",id:"properties",level:2},{value:' edges: IHeapEdges',id:"-edges-iheapedges",level:3},{value:' nodes: IHeapNodes',id:"-nodes-iheapnodes",level:3},{value:"Methods",id:"methods",level:2},{value:'getAnyObjectWithClassName(className)',id:"getanyobjectwithclassnameclassname",level:3},{value:'getNodeById(id)',id:"getnodebyidid",level:3},{value:'getNodesByIdSet(ids)',id:"getnodesbyidsetids",level:3},{value:'getNodesByIds(ids)',id:"getnodesbyidsids",level:3},{value:'hasObjectWithClassName(className)',id:"hasobjectwithclassnameclassname",level:3},{value:'hasObjectWithPropertyName(nameOrIndex)',id:"hasobjectwithpropertynamenameorindex",level:3},{value:'hasObjectWithTag(tag)',id:"hasobjectwithtagtag",level:3}],m={toc:i},c="wrapper";function g(e){let{components:a,...n}=e;return(0,r.yg)(c,(0,t.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"A heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects. For more details\non the structure of nodes and edges in the heap graph, check out\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," and ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"),"."),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-edges-iheapedges"},(0,r.yg)("a",{id:"edges",name:"edges"})," ",(0,r.yg)("strong",{parentName:"h3"},"edges"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdges"))),(0,r.yg)("p",null,"A pseudo array containing all heap graph edges (references to heap objects\nin heap). A JS heap could contain millions of references, so memlab uses\na pseudo array as the collection of all the heap edges. The pseudo\narray provides API to query and traverse all heap references."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // get the total number of heap references\n heap.edges.length;\n\n heap.edges.forEach((edge: IHeapEdge) => {\n // traverse each reference in the heap\n });\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1332"},"core/src/lib/Types.ts:1332"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-nodes-iheapnodes"},(0,r.yg)("a",{id:"nodes",name:"nodes"})," ",(0,r.yg)("strong",{parentName:"h3"},"nodes"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNodes"))),(0,r.yg)("p",null,"A pseudo array containing all heap graph nodes (JS objects in heap).\nA JS heap could contain millions of heap objects, so memlab uses\na pseudo array as the collection of all the heap objects. The pseudo\narray provides API to query and traverse all heap objects."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // get the total number of heap objects\n heap.nodes.length;\n\n heap.nodes.forEach((node: IHeapNode) => {\n // traverse each heap object\n });\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1306"},"core/src/lib/Types.ts:1306"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getanyobjectwithclassnameclassname"},(0,r.yg)("a",{id:"getanyobjectwithclassname"}),(0,r.yg)("strong",{parentName:"h3"},"getAnyObjectWithClassName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"className"),")"),(0,r.yg)("p",null,"Search for the heap and get one of the JS object instances with\na specified constructor name (if there is any)."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"className"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | The constructor name of the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | a handle pointing to any one of the object instances, returns\n",(0,r.yg)("inlineCode",{parentName:"p"},"null")," if no such object exists in the heap.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {takeNodeMinimalHeap} from '@memlab/core';\n\nclass TestObject {\n public arr1 = [1, 2, 3];\n public arr2 = ['1', '2', '3'];\n}\n\n(async function () {\n const obj = new TestObject();\n // get a heap snapshot of the current program state\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n const node = heap.getAnyObjectWithClassName('TestObject');\n console.log(node?.name); // should be 'TestObject'\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1473"},"core/src/lib/Types.ts:1473"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodebyidid"},(0,r.yg)("a",{id:"getnodebyid"}),(0,r.yg)("strong",{parentName:"h3"},"getNodeById"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"id"),")"),(0,r.yg)("p",null,"If you have the id of a heap node (JS object in heap), use this API\nto get an ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," associated with the id."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"id"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number")," | id of the heap node (JS object in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the API returns ",(0,r.yg)("inlineCode",{parentName:"p"},"null")," if no heap object has the specified id.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const node = heap.getNodeById(351);\n node?.id; // should be 351\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1354"},"core/src/lib/Types.ts:1354"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodesbyidsetids"},(0,r.yg)("a",{id:"getnodesbyidset"}),(0,r.yg)("strong",{parentName:"h3"},"getNodesByIdSet"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"ids"),")"),(0,r.yg)("p",null,"Given a set of ids of heap nodes (JS objects in heap), use this API\nto get a set of those heap nodes."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"number"),">"," | id set of the heap nodes (JS objects in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Set"),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | a set of those heap nodes. The set will only include\nnodes that are found in the heap. If none of the input ids are found,\nthis API will return an empty set.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // suppose 1000 is not a valid id in the heap\n const set = heap.getNodesByIdSet(new Set([1, 2, 1000, 3]));\n set // should be Set([node1, node2, node3])\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1406"},"core/src/lib/Types.ts:1406"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodesbyidsids"},(0,r.yg)("a",{id:"getnodesbyids"}),(0,r.yg)("strong",{parentName:"h3"},"getNodesByIds"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"ids"),")"),(0,r.yg)("p",null,"Given an array of ids of heap nodes (JS objects in heap), use this API\nto get an array of those heap nodes."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number"),"[] | id array of the heap nodes (JS objects in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">","[] | an array of those heap nodes. The return array will preserve the\norder of the input array. If an id is not found in the heap, the\ncorresponding element in the return array will be ",(0,r.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // suppose 1000 is not a valid id in the heap\n const nodes = heap.getNodesByIds([1, 2, 1000, 3]);\n nodes // should be [node1, node2, null, node3]\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1380"},"core/src/lib/Types.ts:1380"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithclassnameclassname"},(0,r.yg)("a",{id:"hasobjectwithclassname"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithClassName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"className"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na specified constructor name."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"className"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | The constructor name of the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," if there is at least one such object in the heap")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),": you can write a jest unit test with memory assertions:"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"// save as example.test.ts\nimport type {IHeapSnapshot, Nullable} from '@memlab/core';\nimport {config, takeNodeMinimalHeap} from '@memlab/core';\n\nclass TestObject {\n public arr1 = [1, 2, 3];\n public arr2 = ['1', '2', '3'];\n}\n\ntest('memory test with heap assertion', async () => {\n config.muteConsole = true; // no console output\n\n let obj: Nullable = new TestObject();\n // get a heap snapshot of the current program state\n let heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // call some function that may add references to obj\n rabbitHole(obj)\n\n expect(heap.hasObjectWithClassName('TestObject')).toBe(true);\n obj = null;\n\n heap = await takeNodeMinimalHeap();\n // if rabbitHole does not have any side effect that\n // adds new references to obj, then obj can be GCed\n expect(heap.hasObjectWithClassName('TestObject')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1445"},"core/src/lib/Types.ts:1445"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithpropertynamenameorindex"},(0,r.yg)("a",{id:"hasobjectwithpropertyname"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithPropertyName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"nameOrIndex"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na specified property name."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"nameOrIndex"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"li"},"number")," | The property name (string) or element index (number) on the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," if there is at least one such object in the heap")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const object = {'memlab-test-heap-property': 'memlab-test-heap-value'};\n\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // should be true\n console.log(heap.hasObjectWithPropertyName('memlab-test-heap-property'));\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1499"},"core/src/lib/Types.ts:1499"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithtagtag"},(0,r.yg)("a",{id:"hasobjectwithtag"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithTag"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"tag"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na marker tagged by ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#tagobject"},"tagObject"),"."),(0,r.yg)("p",null,"The ",(0,r.yg)("inlineCode",{parentName:"p"},"tagObject")," API does not modify the object instance in any way\n(e.g., no additional or hidden properties added to the tagged object)."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"tag"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | marker name on the object instances tagged by ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#tagobject"},"tagObject")))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | returns ",(0,r.yg)("inlineCode",{parentName:"li"},"true")," if there is at least one such object in the heap")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, AnyValue} from '@memlab/core';\nimport {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';\n\ntest('memory test', async () => {\n config.muteConsole = true;\n const o1: AnyValue = {};\n let o2: AnyValue = {};\n\n // tag o1 with marker: \"memlab-mark-1\", does not modify o1 in any way\n tagObject(o1, 'memlab-mark-1');\n // tag o2 with marker: \"memlab-mark-2\", does not modify o2 in any way\n tagObject(o2, 'memlab-mark-2');\n\n o2 = null;\n\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // expect object with marker \"memlab-mark-1\" exists\n expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);\n\n // expect object with marker \"memlab-mark-2\" can be GCed\n expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1537"},"core/src/lib/Types.ts:1537"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[1456],{5680:(e,a,n)=>{n.d(a,{xA:()=>m,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=t.createContext({}),i=function(e){var a=t.useContext(s),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},m=function(e){var a=i(e.components);return t.createElement(s.Provider,{value:a},e.children)},c="mdxType",g={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},d=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),c=i(n),d=r,y=c["".concat(s,".").concat(d)]||c[d]||g[d]||o;return n?t.createElement(y,l(l({ref:a},m),{},{components:n})):t.createElement(y,l({ref:a},m))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var o=n.length,l=new Array(o);l[0]=d;var p={};for(var s in a)hasOwnProperty.call(a,s)&&(p[s]=a[s]);p.originalType=e,p[c]="string"==typeof e?e:r,l[1]=p;for(var i=2;i{n.r(a),n.d(a,{assets:()=>s,contentTitle:()=>l,default:()=>g,frontMatter:()=>o,metadata:()=>p,toc:()=>i});var t=n(8168),r=(n(6540),n(5680));const o={id:"core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",sidebar_label:"IHeapSnapshot",custom_edit_url:null},l=void 0,p={unversionedId:"api/interfaces/core_src.IHeapSnapshot",id:"api/interfaces/core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",description:"A heap snapshot is generally a graph where graph nodes are JS heap objects",source:"@site/docs/api/interfaces/core_src.IHeapSnapshot.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapSnapshot",title:"Interface: IHeapSnapshot",sidebar_label:"IHeapSnapshot",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},next:{title:"IHeapStringNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapStringNode"}},s={},i=[{value:"Properties",id:"properties",level:2},{value:' edges: IHeapEdges',id:"-edges-iheapedges",level:3},{value:' nodes: IHeapNodes',id:"-nodes-iheapnodes",level:3},{value:"Methods",id:"methods",level:2},{value:'getAnyObjectWithClassName(className)',id:"getanyobjectwithclassnameclassname",level:3},{value:'getNodeById(id)',id:"getnodebyidid",level:3},{value:'getNodesByIdSet(ids)',id:"getnodesbyidsetids",level:3},{value:'getNodesByIds(ids)',id:"getnodesbyidsids",level:3},{value:'hasObjectWithClassName(className)',id:"hasobjectwithclassnameclassname",level:3},{value:'hasObjectWithPropertyName(nameOrIndex)',id:"hasobjectwithpropertynamenameorindex",level:3},{value:'hasObjectWithTag(tag)',id:"hasobjectwithtagtag",level:3}],m={toc:i},c="wrapper";function g(e){let{components:a,...n}=e;return(0,r.yg)(c,(0,t.A)({},m,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"A heap snapshot is generally a graph where graph nodes are JS heap objects\nand graph edges are JS references among JS heap objects. For more details\non the structure of nodes and edges in the heap graph, check out\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," and ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"),"."),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-edges-iheapedges"},(0,r.yg)("a",{id:"edges",name:"edges"})," ",(0,r.yg)("strong",{parentName:"h3"},"edges"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapEdges"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapEdges"))),(0,r.yg)("p",null,"A pseudo array containing all heap graph edges (references to heap objects\nin heap). A JS heap could contain millions of references, so memlab uses\na pseudo array as the collection of all the heap edges. The pseudo\narray provides API to query and traverse all heap references."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // get the total number of heap references\n heap.edges.length;\n\n heap.edges.forEach((edge: IHeapEdge) => {\n // traverse each reference in the heap\n });\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1332"},"core/src/lib/Types.ts:1332"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-nodes-iheapnodes"},(0,r.yg)("a",{id:"nodes",name:"nodes"})," ",(0,r.yg)("strong",{parentName:"h3"},"nodes"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/interfaces/core_src.IHeapNodes"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNodes"))),(0,r.yg)("p",null,"A pseudo array containing all heap graph nodes (JS objects in heap).\nA JS heap could contain millions of heap objects, so memlab uses\na pseudo array as the collection of all the heap objects. The pseudo\narray provides API to query and traverse all heap objects."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNode} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // get the total number of heap objects\n heap.nodes.length;\n\n heap.nodes.forEach((node: IHeapNode) => {\n // traverse each heap object\n });\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1306"},"core/src/lib/Types.ts:1306"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"getanyobjectwithclassnameclassname"},(0,r.yg)("a",{id:"getanyobjectwithclassname"}),(0,r.yg)("strong",{parentName:"h3"},"getAnyObjectWithClassName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"className"),")"),(0,r.yg)("p",null,"Search for the heap and get one of the JS object instances with\na specified constructor name (if there is any)."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"className"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | The constructor name of the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | a handle pointing to any one of the object instances, returns\n",(0,r.yg)("inlineCode",{parentName:"p"},"null")," if no such object exists in the heap.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {takeNodeMinimalHeap} from '@memlab/core';\n\nclass TestObject {\n public arr1 = [1, 2, 3];\n public arr2 = ['1', '2', '3'];\n}\n\n(async function () {\n const obj = new TestObject();\n // get a heap snapshot of the current program state\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n const node = heap.getAnyObjectWithClassName('TestObject');\n console.log(node?.name); // should be 'TestObject'\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1473"},"core/src/lib/Types.ts:1473"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodebyidid"},(0,r.yg)("a",{id:"getnodebyid"}),(0,r.yg)("strong",{parentName:"h3"},"getNodeById"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"id"),")"),(0,r.yg)("p",null,"If you have the id of a heap node (JS object in heap), use this API\nto get an ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," associated with the id."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"id"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number")," | id of the heap node (JS object in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | the API returns ",(0,r.yg)("inlineCode",{parentName:"p"},"null")," if no heap object has the specified id.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const node = heap.getNodeById(351);\n node?.id; // should be 351\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1354"},"core/src/lib/Types.ts:1354"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodesbyidsetids"},(0,r.yg)("a",{id:"getnodesbyidset"}),(0,r.yg)("strong",{parentName:"h3"},"getNodesByIdSet"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"ids"),")"),(0,r.yg)("p",null,"Given a set of ids of heap nodes (JS objects in heap), use this API\nto get a set of those heap nodes."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set"),"<",(0,r.yg)("inlineCode",{parentName:"li"},"number"),">"," | id set of the heap nodes (JS objects in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"Set"),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | a set of those heap nodes. The set will only include\nnodes that are found in the heap. If none of the input ids are found,\nthis API will return an empty set.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // suppose 1000 is not a valid id in the heap\n const set = heap.getNodesByIdSet(new Set([1, 2, 1000, 3]));\n set // should be Set([node1, node2, node3])\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1406"},"core/src/lib/Types.ts:1406"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"getnodesbyidsids"},(0,r.yg)("a",{id:"getnodesbyids"}),(0,r.yg)("strong",{parentName:"h3"},"getNodesByIds"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"ids"),")"),(0,r.yg)("p",null,"Given an array of ids of heap nodes (JS objects in heap), use this API\nto get an array of those heap nodes."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"ids"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number"),"[] | id array of the heap nodes (JS objects in heap) you would like to query"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,r.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,r.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">","[] | an array of those heap nodes. The return array will preserve the\norder of the input array. If an id is not found in the heap, the\ncorresponding element in the return array will be ",(0,r.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // suppose 1000 is not a valid id in the heap\n const nodes = heap.getNodesByIds([1, 2, 1000, 3]);\n nodes // should be [node1, node2, null, node3]\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1380"},"core/src/lib/Types.ts:1380"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithclassnameclassname"},(0,r.yg)("a",{id:"hasobjectwithclassname"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithClassName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"className"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na specified constructor name."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"className"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | The constructor name of the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," if there is at least one such object in the heap")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),": you can write a jest unit test with memory assertions:"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"// save as example.test.ts\nimport type {IHeapSnapshot, Nullable} from '@memlab/core';\nimport {config, takeNodeMinimalHeap} from '@memlab/core';\n\nclass TestObject {\n public arr1 = [1, 2, 3];\n public arr2 = ['1', '2', '3'];\n}\n\ntest('memory test with heap assertion', async () => {\n config.muteConsole = true; // no console output\n\n let obj: Nullable = new TestObject();\n // get a heap snapshot of the current program state\n let heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // call some function that may add references to obj\n rabbitHole(obj)\n\n expect(heap.hasObjectWithClassName('TestObject')).toBe(true);\n obj = null;\n\n heap = await takeNodeMinimalHeap();\n // if rabbitHole does not have any side effect that\n // adds new references to obj, then obj can be GCed\n expect(heap.hasObjectWithClassName('TestObject')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1445"},"core/src/lib/Types.ts:1445"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithpropertynamenameorindex"},(0,r.yg)("a",{id:"hasobjectwithpropertyname"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithPropertyName"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"nameOrIndex"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na specified property name."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"nameOrIndex"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," ","|"," ",(0,r.yg)("inlineCode",{parentName:"li"},"number")," | The property name (string) or element index (number) on the object instance"))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"p"},"boolean")," | returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," if there is at least one such object in the heap")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const object = {'memlab-test-heap-property': 'memlab-test-heap-value'};\n\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n // should be true\n console.log(heap.hasObjectWithPropertyName('memlab-test-heap-property'));\n})();\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1499"},"core/src/lib/Types.ts:1499"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"hasobjectwithtagtag"},(0,r.yg)("a",{id:"hasobjectwithtag"}),(0,r.yg)("strong",{parentName:"h3"},"hasObjectWithTag"),"(",(0,r.yg)("inlineCode",{parentName:"h3"},"tag"),")"),(0,r.yg)("p",null,"Search for the heap and check if there is any JS object instance with\na marker tagged by ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#tagobject"},"tagObject"),"."),(0,r.yg)("p",null,"The ",(0,r.yg)("inlineCode",{parentName:"p"},"tagObject")," API does not modify the object instance in any way\n(e.g., no additional or hidden properties added to the tagged object)."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Parameters"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"tag"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | marker name on the object instances tagged by ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#tagobject"},"tagObject")))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | returns ",(0,r.yg)("inlineCode",{parentName:"li"},"true")," if there is at least one such object in the heap")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, AnyValue} from '@memlab/core';\nimport {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';\n\ntest('memory test', async () => {\n config.muteConsole = true;\n const o1: AnyValue = {};\n let o2: AnyValue = {};\n\n // tag o1 with marker: \"memlab-mark-1\", does not modify o1 in any way\n tagObject(o1, 'memlab-mark-1');\n // tag o2 with marker: \"memlab-mark-2\", does not modify o2 in any way\n tagObject(o2, 'memlab-mark-2');\n\n o2 = null;\n\n const heap: IHeapSnapshot = await takeNodeMinimalHeap();\n\n // expect object with marker \"memlab-mark-1\" exists\n expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);\n\n // expect object with marker \"memlab-mark-2\" can be GCed\n expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);\n\n}, 30000);\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1537"},"core/src/lib/Types.ts:1537"))))))}g.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/e012388a.1d2da296.js b/assets/js/e012388a.6146abb3.js similarity index 92% rename from assets/js/e012388a.1d2da296.js rename to assets/js/e012388a.6146abb3.js index e0677a0c..5c9156b5 100644 --- a/assets/js/e012388a.1d2da296.js +++ b/assets/js/e012388a.6146abb3.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8953],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),s=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},c=function(e){var a=s(e.components);return r.createElement(p.Provider,{value:a},e.children)},m="mdxType",d={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},g=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,o=e.originalType,p=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),m=s(n),g=t,y=m["".concat(p,".").concat(g)]||m[g]||d[g]||o;return n?r.createElement(y,l(l({ref:a},c),{},{components:n})):r.createElement(y,l({ref:a},c))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var o=n.length,l=new Array(o);l[0]=g;var i={};for(var p in a)hasOwnProperty.call(a,p)&&(i[p]=a[p]);i.originalType=e,i[m]="string"==typeof e?e:t,l[1]=i;for(var s=2;s{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>l,default:()=>d,frontMatter:()=>o,metadata:()=>i,toc:()=>s});var r=n(8168),t=(n(6540),n(5680));const o={id:"core_src.IHeapNodes",title:"Interface: IHeapNodes",sidebar_label:"IHeapNodes",custom_edit_url:null},l=void 0,i={unversionedId:"api/interfaces/core_src.IHeapNodes",id:"api/interfaces/core_src.IHeapNodes",title:"Interface: IHeapNodes",description:"A pseudo array containing all heap graph nodes (JS objects",source:"@site/docs/api/interfaces/core_src.IHeapNodes.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapNodes",title:"Interface: IHeapNodes",sidebar_label:"IHeapNodes",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode"},next:{title:"IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"}},p={},s=[{value:"Properties",id:"properties",level:2},{value:' length: number',id:"-length-number",level:3},{value:"Methods",id:"methods",level:2},{value:'forEach(callback)',id:"foreachcallback",level:3},{value:'get(index)',id:"getindex",level:3}],c={toc:s},m="wrapper";function d(e){let{components:a,...n}=e;return(0,t.yg)(m,(0,r.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"A pseudo array containing all heap graph nodes (JS objects\nin heap). A JS heap could contain millions of objects, so memlab uses\na pseudo array as the collection of all the heap nodes. The pseudo\narray provides API to query and traverse all heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," modifying this pseudo array is not recommended"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNodes} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const nodes: IHeapNodes = heap.nodes;\n nodes.length;\n nodes.get(0);\n nodes.forEach((node, i) => {\n if (stopIteration) {\n return false;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-length-number"},(0,t.yg)("a",{id:"length",name:"length"})," ",(0,t.yg)("strong",{parentName:"h3"},"length"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of nodes in heap graph (or JS objects in heap\nsnapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2263"},"core/src/lib/Types.ts:2263"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"foreachcallback"},(0,t.yg)("a",{id:"foreach"}),(0,t.yg)("strong",{parentName:"h3"},"forEach"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"Iterate over all array elements and apply the callback\nto each element in ascending order of element index."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),", ",(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"void")," | the callback does not need to return any value, if the callback returns ",(0,t.yg)("inlineCode",{parentName:"li"},"false")," when iterating on element at index ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),", then all elements after ",(0,t.yg)("inlineCode",{parentName:"li"},"i")," won't be iterated."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2279"},"core/src/lib/Types.ts:2279"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getindex"},(0,t.yg)("a",{id:"get"}),(0,t.yg)("strong",{parentName:"h3"},"get"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"index"),")"),(0,t.yg)("p",null,"get an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," element at the specified index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the index of an element in the pseudo array, the index ranges from 0 to array length - 1. Notice that this is not the heap node id."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | When 0 <= ",(0,t.yg)("inlineCode",{parentName:"p"},"index")," < array.length, this API returns the element\nat the specified index, otherwise it returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L2271"},"core/src/lib/Types.ts:2271"))))))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[8953],{5680:(e,a,n)=>{n.d(a,{xA:()=>c,yg:()=>y});var r=n(6540);function t(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function o(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);a&&(r=r.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var a=1;a=0||(t[n]=e[n]);return t}(e,a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}var p=r.createContext({}),s=function(e){var a=r.useContext(p),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},c=function(e){var a=s(e.components);return r.createElement(p.Provider,{value:a},e.children)},d="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return r.createElement(r.Fragment,{},a)}},g=r.forwardRef((function(e,a){var n=e.components,t=e.mdxType,o=e.originalType,p=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),d=s(n),g=t,y=d["".concat(p,".").concat(g)]||d[g]||m[g]||o;return n?r.createElement(y,l(l({ref:a},c),{},{components:n})):r.createElement(y,l({ref:a},c))}));function y(e,a){var n=arguments,t=a&&a.mdxType;if("string"==typeof e||t){var o=n.length,l=new Array(o);l[0]=g;var i={};for(var p in a)hasOwnProperty.call(a,p)&&(i[p]=a[p]);i.originalType=e,i[d]="string"==typeof e?e:t,l[1]=i;for(var s=2;s{n.r(a),n.d(a,{assets:()=>p,contentTitle:()=>l,default:()=>m,frontMatter:()=>o,metadata:()=>i,toc:()=>s});var r=n(8168),t=(n(6540),n(5680));const o={id:"core_src.IHeapNodes",title:"Interface: IHeapNodes",sidebar_label:"IHeapNodes",custom_edit_url:null},l=void 0,i={unversionedId:"api/interfaces/core_src.IHeapNodes",id:"api/interfaces/core_src.IHeapNodes",title:"Interface: IHeapNodes",description:"A pseudo array containing all heap graph nodes (JS objects",source:"@site/docs/api/interfaces/core_src.IHeapNodes.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IHeapNodes",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNodes",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IHeapNodes",title:"Interface: IHeapNodes",sidebar_label:"IHeapNodes",custom_edit_url:null},sidebar:"sidebar",previous:{title:"IHeapNode",permalink:"/memlab/docs/api/interfaces/core_src.IHeapNode"},next:{title:"IHeapSnapshot",permalink:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"}},p={},s=[{value:"Properties",id:"properties",level:2},{value:' length: number',id:"-length-number",level:3},{value:"Methods",id:"methods",level:2},{value:'forEach(callback)',id:"foreachcallback",level:3},{value:'get(index)',id:"getindex",level:3}],c={toc:s},d="wrapper";function m(e){let{components:a,...n}=e;return(0,t.yg)(d,(0,r.A)({},c,n,{components:a,mdxType:"MDXLayout"}),(0,t.yg)("p",null,"A pseudo array containing all heap graph nodes (JS objects\nin heap). A JS heap could contain millions of objects, so memlab uses\na pseudo array as the collection of all the heap nodes. The pseudo\narray provides API to query and traverse all heap objects."),(0,t.yg)("p",null,(0,t.yg)("strong",{parentName:"p"},(0,t.yg)("inlineCode",{parentName:"strong"},"readonly"))," modifying this pseudo array is not recommended"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Examples"),":")),(0,t.yg)("pre",null,(0,t.yg)("code",{parentName:"pre",className:"language-typescript"},"import type {IHeapSnapshot, IHeapNodes} from '@memlab/core';\nimport {dumpNodeHeapSnapshot} from '@memlab/core';\nimport {getFullHeapFromFile} from '@memlab/heap-analysis';\n\n(async function () {\n const heapFile = dumpNodeHeapSnapshot();\n const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);\n\n const nodes: IHeapNodes = heap.nodes;\n nodes.length;\n nodes.get(0);\n nodes.forEach((node, i) => {\n if (stopIteration) {\n return false;\n }\n });\n})();\n")),(0,t.yg)("h2",{id:"properties"},"Properties"),(0,t.yg)("h3",{id:"-length-number"},(0,t.yg)("a",{id:"length",name:"length"})," ",(0,t.yg)("strong",{parentName:"h3"},"length"),": ",(0,t.yg)("inlineCode",{parentName:"h3"},"number")),(0,t.yg)("p",null,"The total number of nodes in heap graph (or JS objects in heap\nsnapshot)."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2263"},"core/src/lib/Types.ts:2263"))))),(0,t.yg)("h2",{id:"methods"},"Methods"),(0,t.yg)("h3",{id:"foreachcallback"},(0,t.yg)("a",{id:"foreach"}),(0,t.yg)("strong",{parentName:"h3"},"forEach"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"callback"),")"),(0,t.yg)("p",null,"Iterate over all array elements and apply the callback\nto each element in ascending order of element index."),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Parameters"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"callback"),": (",(0,t.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,t.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),", ",(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number"),") => ",(0,t.yg)("inlineCode",{parentName:"li"},"boolean")," ","|"," ",(0,t.yg)("inlineCode",{parentName:"li"},"void")," | the callback does not need to return any value, if the callback returns ",(0,t.yg)("inlineCode",{parentName:"li"},"false")," when iterating on element at index ",(0,t.yg)("inlineCode",{parentName:"li"},"i"),", then all elements after ",(0,t.yg)("inlineCode",{parentName:"li"},"i")," won't be iterated."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Returns"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"void")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("strong",{parentName:"li"},"Source"),":",(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2279"},"core/src/lib/Types.ts:2279"))))),(0,t.yg)("hr",null),(0,t.yg)("h3",{id:"getindex"},(0,t.yg)("a",{id:"get"}),(0,t.yg)("strong",{parentName:"h3"},"get"),"(",(0,t.yg)("inlineCode",{parentName:"h3"},"index"),")"),(0,t.yg)("p",null,"get an ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode")," element at the specified index"),(0,t.yg)("ul",null,(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("inlineCode",{parentName:"li"},"index"),": ",(0,t.yg)("inlineCode",{parentName:"li"},"number")," | the index of an element in the pseudo array, the index ranges from 0 to array length - 1. Notice that this is not the heap node id."))),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Returns"),": ",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/core_src#nullable"},(0,t.yg)("inlineCode",{parentName:"a"},"Nullable")),"<",(0,t.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},(0,t.yg)("inlineCode",{parentName:"a"},"IHeapNode")),">"," | When 0 <= ",(0,t.yg)("inlineCode",{parentName:"p"},"index")," < array.length, this API returns the element\nat the specified index, otherwise it returns ",(0,t.yg)("inlineCode",{parentName:"p"},"null"),".")),(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("p",{parentName:"li"},(0,t.yg)("strong",{parentName:"p"},"Source"),":"),(0,t.yg)("ul",{parentName:"li"},(0,t.yg)("li",{parentName:"ul"},(0,t.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L2271"},"core/src/lib/Types.ts:2271"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/e4c6f3cc.14f34b89.js b/assets/js/e4c6f3cc.d050fdd8.js similarity index 97% rename from assets/js/e4c6f3cc.14f34b89.js rename to assets/js/e4c6f3cc.d050fdd8.js index fa566751..20714554 100644 --- a/assets/js/e4c6f3cc.14f34b89.js +++ b/assets/js/e4c6f3cc.d050fdd8.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9600],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function r(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},h=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,r=e.originalType,o=e.parentName,y=i(e,["components","mdxType","originalType","parentName"]),u=p(n),h=s,g=u["".concat(o,".").concat(h)]||u[h]||c[h]||r;return n?t.createElement(g,l(l({ref:a},y),{},{components:n})):t.createElement(g,l({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var r=n.length,l=new Array(r);l[0]=h;var i={};for(var o in a)hasOwnProperty.call(a,o)&&(i[o]=a[o]);i.originalType=e,i[u]="string"==typeof e?e:s,l[1]=i;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>l,default:()=>c,frontMatter:()=>r,metadata:()=>i,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const r={id:"heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",sidebar_label:"ShapeUnboundGrowthAnalysis",custom_edit_url:null},l=void 0,i={unversionedId:"api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",id:"api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",sidebar_label:"ShapeUnboundGrowthAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},next:{title:"StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ShapeUnboundGrowthAnalysis()',id:"new-shapeunboundgrowthanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getShapesWithUnboundGrowth()',id:"getshapeswithunboundgrowth",level:3}],y={toc:p},u="wrapper";function c(e){let{components:a,...n}=e;return(0,s.yg)(u,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ShapeUnboundGrowthAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-shapeunboundgrowthanalysis"},(0,s.yg)("a",{id:"new shapeunboundgrowthanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ShapeUnboundGrowthAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,s.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts#L43"},"heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts:43"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getshapeswithunboundgrowth"},(0,s.yg)("a",{id:"getshapeswithunboundgrowth"}),(0,s.yg)("strong",{parentName:"h3"},"getShapesWithUnboundGrowth"),"()"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"ShapeSummary"),"[]"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts#L71"},"heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts:71"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9600],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function r(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function l(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):l(l({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},h=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,r=e.originalType,o=e.parentName,y=i(e,["components","mdxType","originalType","parentName"]),u=p(n),h=s,g=u["".concat(o,".").concat(h)]||u[h]||c[h]||r;return n?t.createElement(g,l(l({ref:a},y),{},{components:n})):t.createElement(g,l({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var r=n.length,l=new Array(r);l[0]=h;var i={};for(var o in a)hasOwnProperty.call(a,o)&&(i[o]=a[o]);i.originalType=e,i[u]="string"==typeof e?e:s,l[1]=i;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>l,default:()=>c,frontMatter:()=>r,metadata:()=>i,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const r={id:"heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",sidebar_label:"ShapeUnboundGrowthAnalysis",custom_edit_url:null},l=void 0,i={unversionedId:"api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",id:"api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ShapeUnboundGrowthAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ShapeUnboundGrowthAnalysis",title:"Class: ShapeUnboundGrowthAnalysis",sidebar_label:"ShapeUnboundGrowthAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ObjectUnboundGrowthAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectUnboundGrowthAnalysis"},next:{title:"StringAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.StringAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ShapeUnboundGrowthAnalysis()',id:"new-shapeunboundgrowthanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotsInDirectory(directory, options?)',id:"analyzesnapshotsindirectorydirectory-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3},{value:'getShapesWithUnboundGrowth()',id:"getshapeswithunboundgrowth",level:3}],y={toc:p},u="wrapper";function c(e){let{components:a,...n}=e;return(0,s.yg)(u,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ShapeUnboundGrowthAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-shapeunboundgrowthanalysis"},(0,s.yg)("a",{id:"new shapeunboundgrowthanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ShapeUnboundGrowthAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotsindirectorydirectory-options"},(0,s.yg)("a",{id:"analyzesnapshotsindirectory"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotsInDirectory"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"directory"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a series of heap snapshot files"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"directory"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory holding a series of ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," files, all snapshot files will be loaded and analyzed in the alphanumerically ascending order of those snapshot file names."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory);\n// query analysis-specific and structured results\nconst shapes = analysis.getShapesWithUnboundGrowth();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new ShapeUnboundGrowthAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotsInDirectory(snapshotDirectory, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L148"},"heap-analysis/src/BaseAnalysis.ts:148"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts#L43"},"heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts:43"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getshapeswithunboundgrowth"},(0,s.yg)("a",{id:"getshapeswithunboundgrowth"}),(0,s.yg)("strong",{parentName:"h3"},"getShapesWithUnboundGrowth"),"()"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"ShapeSummary"),"[]"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts#L71"},"heap-analysis/src/plugins/ShapeUnboundGrowthAnalysis.ts:71"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/f40f92ec.840cd345.js b/assets/js/f40f92ec.613fb13e.js similarity index 95% rename from assets/js/f40f92ec.840cd345.js rename to assets/js/f40f92ec.613fb13e.js index 563c4738..0e657253 100644 --- a/assets/js/f40f92ec.840cd345.js +++ b/assets/js/f40f92ec.613fb13e.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[346],{5680:(e,t,a)=>{a.d(t,{xA:()=>u,yg:()=>y});var r=a(6540);function n(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function s(e){for(var t=1;t=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var i=r.createContext({}),p=function(e){var t=r.useContext(i),a=t;return e&&(a="function"==typeof e?e(t):s(s({},t),e)),a},u=function(e){var t=p(e.components);return r.createElement(i.Provider,{value:t},e.children)},g="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var a=e.components,n=e.mdxType,l=e.originalType,i=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),g=p(a),m=n,y=g["".concat(i,".").concat(m)]||g[m]||c[m]||l;return a?r.createElement(y,s(s({ref:t},u),{},{components:a})):r.createElement(y,s({ref:t},u))}));function y(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var l=a.length,s=new Array(l);s[0]=m;var o={};for(var i in t)hasOwnProperty.call(t,i)&&(o[i]=t[i]);o.originalType=e,o[g]="string"==typeof e?e:n,s[1]=o;for(var p=2;p{a.r(t),a.d(t,{assets:()=>i,contentTitle:()=>s,default:()=>c,frontMatter:()=>l,metadata:()=>o,toc:()=>p});var r=a(8168),n=(a(6540),a(5680));const l={id:"api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",sidebar_label:"BrowserInteractionResultReader",custom_edit_url:null},s=void 0,o={unversionedId:"api/classes/api_src.BrowserInteractionResultReader",id:"api/classes/api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",description:"A utility entity to read all generated files from",source:"@site/docs/api/classes/api_src.BrowserInteractionResultReader.md",sourceDirName:"api/classes",slug:"/api/classes/api_src.BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",sidebar_label:"BrowserInteractionResultReader",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode"},next:{title:"SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader"}},i={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Methods",id:"methods",level:2},{value:'cleanup()',id:"cleanup",level:3},{value:'getConsoleBackupFile()',id:"getconsolebackupfile",level:3},{value:'getInteractionSteps()',id:"getinteractionsteps",level:3},{value:'getRootDirectory()',id:"getrootdirectory",level:3},{value:'getRunMetaInfo()',id:"getrunmetainfo",level:3},{value:'getSnapshotFileDir()',id:"getsnapshotfiledir",level:3},{value:'getSnapshotFiles()',id:"getsnapshotfiles",level:3},{value:'Static from(workDir?)',id:"static-fromworkdir",level:3}],u={toc:p},g="wrapper";function c(e){let{components:t,...a}=e;return(0,n.yg)(g,(0,r.A)({},u,a,{components:t,mdxType:"MDXLayout"}),(0,n.yg)("p",null,"A utility entity to read all generated files from\nthe directory holding the data and results from the\nlast MemLab browser interaction run"),(0,n.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("inlineCode",{parentName:"p"},"default")),(0,n.yg)("p",{parentName:"li"},"\u21b3 ",(0,n.yg)("strong",{parentName:"p"},(0,n.yg)("inlineCode",{parentName:"strong"},"BrowserInteractionResultReader"))))),(0,n.yg)("h2",{id:"methods"},"Methods"),(0,n.yg)("h3",{id:"cleanup"},(0,n.yg)("a",{id:"cleanup"}),(0,n.yg)("strong",{parentName:"h3"},"cleanup"),"()"),(0,n.yg)("p",null,"clean up data/files generated from the memlab browser interaction run"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"void")," | no return value"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // delete all data/files generated by takeSnapshots\n result.cleanup();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BaseResultReader.ts#L122"},"api/src/result-reader/BaseResultReader.ts:122"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getconsolebackupfile"},(0,n.yg)("a",{id:"getconsolebackupfile"}),(0,n.yg)("strong",{parentName:"h3"},"getConsoleBackupFile"),"()"),(0,n.yg)("p",null,"This method gets the backup file of the console output."),(0,n.yg)("p",null,"The memlab CLI commands (e.g., ",(0,n.yg)("inlineCode",{parentName:"p"},"memlab find-leaks"),") outputs a\nnon-structured string representation for easy reading, while the\nAPIs (e.g., ",(0,n.yg)("code",null,(0,n.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks")),") return structured leaks\nrepresentation that is handy for post-processing. If you need to\nobtain all the string output from the CLI in the current working directory,\nyou can read them from the CLI output backup file returned by this method."),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the backup file"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots, findLeaks} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n const leaks = await findLeaks(result);\n\n // get the console output backup file\n const consoleBackupFile = result.getConsoleBackupFile();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BaseResultReader.ts#L102"},"api/src/result-reader/BaseResultReader.ts:102"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getinteractionsteps"},(0,n.yg)("a",{id:"getinteractionsteps"}),(0,n.yg)("strong",{parentName:"h3"},"getInteractionSteps"),"()"),(0,n.yg)("p",null,"browser interaction step sequence"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"E2EStepInfo"),"[] | an array of browser interaction step information"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n const steps = result.getInteractionSteps();\n // print each browser interaction's name and JavaScript heap size (in bytes)\n steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L106"},"api/src/result-reader/BrowserInteractionResultReader.ts:106"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getrootdirectory"},(0,n.yg)("a",{id:"getrootdirectory"}),(0,n.yg)("strong",{parentName:"h3"},"getRootDirectory"),"()"),(0,n.yg)("p",null,"get the directory where the data and generated files of\nthe memlab run were stored"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | absolute path of the directory"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the directory that stores all the files\n // generated from the takeSnapshots call\n const dataDir = result.getRootDirectory();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BaseResultReader.ts#L72"},"api/src/result-reader/BaseResultReader.ts:72"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getrunmetainfo"},(0,n.yg)("a",{id:"getrunmetainfo"}),(0,n.yg)("strong",{parentName:"h3"},"getRunMetaInfo"),"()"),(0,n.yg)("p",null,"general meta data of the browser interaction run"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"RunMetaInfo")," | meta data about the entire browser interaction"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n const metaInfo = result.getRunMetaInfo();\n // print all browser web console output\n console.log(metaInfo.browserInfo._consoleMessages.join('\\n'));\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L131"},"api/src/result-reader/BrowserInteractionResultReader.ts:131"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getsnapshotfiledir"},(0,n.yg)("a",{id:"getsnapshotfiledir"}),(0,n.yg)("strong",{parentName:"h3"},"getSnapshotFileDir"),"()"),(0,n.yg)("p",null,"get the directory holding all snapshot files"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the absolute path the directory holding all snapshot files\n const files = result.getSnapshotFileDir();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L84"},"api/src/result-reader/BrowserInteractionResultReader.ts:84"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getsnapshotfiles"},(0,n.yg)("a",{id:"getsnapshotfiles"}),(0,n.yg)("strong",{parentName:"h3"},"getSnapshotFiles"),"()"),(0,n.yg)("p",null,"get all snapshot files generated from last memlab browser interaction"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string"),"[] | an array of snapshot file's absolute path"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get absolute paths of all snapshot files\n const files = result.getSnapshotFiles();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L59"},"api/src/result-reader/BrowserInteractionResultReader.ts:59"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"static-fromworkdir"},(0,n.yg)("a",{id:"from"}),(0,n.yg)("inlineCode",{parentName:"h3"},"Static")," ",(0,n.yg)("strong",{parentName:"h3"},"from"),"(",(0,n.yg)("inlineCode",{parentName:"h3"},"workDir?"),")"),(0,n.yg)("p",null,"build a result reader from a data directory where the data\nand generated files of a memlab run were stored"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("inlineCode",{parentName:"li"},"workDir"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | ",(0,n.yg)("inlineCode",{parentName:"li"},"''")," | absolute path of the data directory"))),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Returns"),": ",(0,n.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,n.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader"))," | the ResultReader instance")),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {BrowserInteractionResultReader} = require('@memlab/api');\n\nconst dataDir = '/tmp/memlab'; // where the last memlab run stores results\nconst reader = BrowserInteractionResultReader.from(dataDir);\nreader.cleanup(); // clean up the results\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L39"},"api/src/result-reader/BrowserInteractionResultReader.ts:39"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[346],{5680:(e,t,a)=>{a.d(t,{xA:()=>u,yg:()=>d});var r=a(6540);function n(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function s(e){for(var t=1;t=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var i=r.createContext({}),p=function(e){var t=r.useContext(i),a=t;return e&&(a="function"==typeof e?e(t):s(s({},t),e)),a},u=function(e){var t=p(e.components);return r.createElement(i.Provider,{value:t},e.children)},g="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var a=e.components,n=e.mdxType,l=e.originalType,i=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),g=p(a),m=n,d=g["".concat(i,".").concat(m)]||g[m]||c[m]||l;return a?r.createElement(d,s(s({ref:t},u),{},{components:a})):r.createElement(d,s({ref:t},u))}));function d(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var l=a.length,s=new Array(l);s[0]=m;var o={};for(var i in t)hasOwnProperty.call(t,i)&&(o[i]=t[i]);o.originalType=e,o[g]="string"==typeof e?e:n,s[1]=o;for(var p=2;p{a.r(t),a.d(t,{assets:()=>i,contentTitle:()=>s,default:()=>c,frontMatter:()=>l,metadata:()=>o,toc:()=>p});var r=a(8168),n=(a(6540),a(5680));const l={id:"api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",sidebar_label:"BrowserInteractionResultReader",custom_edit_url:null},s=void 0,o={unversionedId:"api/classes/api_src.BrowserInteractionResultReader",id:"api/classes/api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",description:"A utility entity to read all generated files from",source:"@site/docs/api/classes/api_src.BrowserInteractionResultReader.md",sourceDirName:"api/classes",slug:"/api/classes/api_src.BrowserInteractionResultReader",permalink:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"api_src.BrowserInteractionResultReader",title:"Class: BrowserInteractionResultReader",sidebar_label:"BrowserInteractionResultReader",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ConsoleMode",permalink:"/memlab/docs/api/enums/api_src.ConsoleMode"},next:{title:"SnapshotResultReader",permalink:"/memlab/docs/api/classes/api_src.SnapshotResultReader"}},i={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Methods",id:"methods",level:2},{value:'cleanup()',id:"cleanup",level:3},{value:'getConsoleBackupFile()',id:"getconsolebackupfile",level:3},{value:'getInteractionSteps()',id:"getinteractionsteps",level:3},{value:'getRootDirectory()',id:"getrootdirectory",level:3},{value:'getRunMetaInfo()',id:"getrunmetainfo",level:3},{value:'getSnapshotFileDir()',id:"getsnapshotfiledir",level:3},{value:'getSnapshotFiles()',id:"getsnapshotfiles",level:3},{value:'Static from(workDir?)',id:"static-fromworkdir",level:3}],u={toc:p},g="wrapper";function c(e){let{components:t,...a}=e;return(0,n.yg)(g,(0,r.A)({},u,a,{components:t,mdxType:"MDXLayout"}),(0,n.yg)("p",null,"A utility entity to read all generated files from\nthe directory holding the data and results from the\nlast MemLab browser interaction run"),(0,n.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("inlineCode",{parentName:"p"},"default")),(0,n.yg)("p",{parentName:"li"},"\u21b3 ",(0,n.yg)("strong",{parentName:"p"},(0,n.yg)("inlineCode",{parentName:"strong"},"BrowserInteractionResultReader"))))),(0,n.yg)("h2",{id:"methods"},"Methods"),(0,n.yg)("h3",{id:"cleanup"},(0,n.yg)("a",{id:"cleanup"}),(0,n.yg)("strong",{parentName:"h3"},"cleanup"),"()"),(0,n.yg)("p",null,"clean up data/files generated from the memlab browser interaction run"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"void")," | no return value"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // delete all data/files generated by takeSnapshots\n result.cleanup();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BaseResultReader.ts#L122"},"api/src/result-reader/BaseResultReader.ts:122"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getconsolebackupfile"},(0,n.yg)("a",{id:"getconsolebackupfile"}),(0,n.yg)("strong",{parentName:"h3"},"getConsoleBackupFile"),"()"),(0,n.yg)("p",null,"This method gets the backup file of the console output."),(0,n.yg)("p",null,"The memlab CLI commands (e.g., ",(0,n.yg)("inlineCode",{parentName:"p"},"memlab find-leaks"),") outputs a\nnon-structured string representation for easy reading, while the\nAPIs (e.g., ",(0,n.yg)("code",null,(0,n.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#findleaks"},"findLeaks")),") return structured leaks\nrepresentation that is handy for post-processing. If you need to\nobtain all the string output from the CLI in the current working directory,\nyou can read them from the CLI output backup file returned by this method."),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the backup file"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots, findLeaks} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n const leaks = await findLeaks(result);\n\n // get the console output backup file\n const consoleBackupFile = result.getConsoleBackupFile();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BaseResultReader.ts#L102"},"api/src/result-reader/BaseResultReader.ts:102"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getinteractionsteps"},(0,n.yg)("a",{id:"getinteractionsteps"}),(0,n.yg)("strong",{parentName:"h3"},"getInteractionSteps"),"()"),(0,n.yg)("p",null,"browser interaction step sequence"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"E2EStepInfo"),"[] | an array of browser interaction step information"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n const steps = result.getInteractionSteps();\n // print each browser interaction's name and JavaScript heap size (in bytes)\n steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L106"},"api/src/result-reader/BrowserInteractionResultReader.ts:106"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getrootdirectory"},(0,n.yg)("a",{id:"getrootdirectory"}),(0,n.yg)("strong",{parentName:"h3"},"getRootDirectory"),"()"),(0,n.yg)("p",null,"get the directory where the data and generated files of\nthe memlab run were stored"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | absolute path of the directory"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the directory that stores all the files\n // generated from the takeSnapshots call\n const dataDir = result.getRootDirectory();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BaseResultReader.ts#L72"},"api/src/result-reader/BaseResultReader.ts:72"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getrunmetainfo"},(0,n.yg)("a",{id:"getrunmetainfo"}),(0,n.yg)("strong",{parentName:"h3"},"getRunMetaInfo"),"()"),(0,n.yg)("p",null,"general meta data of the browser interaction run"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"RunMetaInfo")," | meta data about the entire browser interaction"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n const metaInfo = result.getRunMetaInfo();\n // print all browser web console output\n console.log(metaInfo.browserInfo._consoleMessages.join('\\n'));\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L131"},"api/src/result-reader/BrowserInteractionResultReader.ts:131"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getsnapshotfiledir"},(0,n.yg)("a",{id:"getsnapshotfiledir"}),(0,n.yg)("strong",{parentName:"h3"},"getSnapshotFileDir"),"()"),(0,n.yg)("p",null,"get the directory holding all snapshot files"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of the directory"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get the absolute path the directory holding all snapshot files\n const files = result.getSnapshotFileDir();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L84"},"api/src/result-reader/BrowserInteractionResultReader.ts:84"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"getsnapshotfiles"},(0,n.yg)("a",{id:"getsnapshotfiles"}),(0,n.yg)("strong",{parentName:"h3"},"getSnapshotFiles"),"()"),(0,n.yg)("p",null,"get all snapshot files generated from last memlab browser interaction"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Returns"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string"),"[] | an array of snapshot file's absolute path"),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Examples"),":")),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {takeSnapshots} = require('@memlab/api');\n\n(async function () {\n const scenario = { url: () => 'https://www.npmjs.com'};\n const result = await takeSnapshots({scenario});\n\n // get absolute paths of all snapshot files\n const files = result.getSnapshotFiles();\n})();\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L59"},"api/src/result-reader/BrowserInteractionResultReader.ts:59"))))),(0,n.yg)("hr",null),(0,n.yg)("h3",{id:"static-fromworkdir"},(0,n.yg)("a",{id:"from"}),(0,n.yg)("inlineCode",{parentName:"h3"},"Static")," ",(0,n.yg)("strong",{parentName:"h3"},"from"),"(",(0,n.yg)("inlineCode",{parentName:"h3"},"workDir?"),")"),(0,n.yg)("p",null,"build a result reader from a data directory where the data\nand generated files of a memlab run were stored"),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("inlineCode",{parentName:"li"},"workDir"),": ",(0,n.yg)("inlineCode",{parentName:"li"},"string")," | ",(0,n.yg)("inlineCode",{parentName:"li"},"''")," | absolute path of the data directory"))),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Returns"),": ",(0,n.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/api_src.BrowserInteractionResultReader"},(0,n.yg)("inlineCode",{parentName:"a"},"BrowserInteractionResultReader"))," | the ResultReader instance")),(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("p",{parentName:"li"},(0,n.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,n.yg)("pre",null,(0,n.yg)("code",{parentName:"pre",className:"language-javascript"},"const {BrowserInteractionResultReader} = require('@memlab/api');\n\nconst dataDir = '/tmp/memlab'; // where the last memlab run stores results\nconst reader = BrowserInteractionResultReader.from(dataDir);\nreader.cleanup(); // clean up the results\n")),(0,n.yg)("ul",null,(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("strong",{parentName:"li"},"Source"),":",(0,n.yg)("ul",{parentName:"li"},(0,n.yg)("li",{parentName:"ul"},(0,n.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/api/src/result-reader/BrowserInteractionResultReader.ts#L39"},"api/src/result-reader/BrowserInteractionResultReader.ts:39"))))))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/f8599c11.c0c9117e.js b/assets/js/f8599c11.7647fd3b.js similarity index 97% rename from assets/js/f8599c11.c0c9117e.js rename to assets/js/f8599c11.7647fd3b.js index 68171187..05da3373 100644 --- a/assets/js/f8599c11.c0c9117e.js +++ b/assets/js/f8599c11.7647fd3b.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[233],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},m=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),m=s,g=c["".concat(o,".").concat(m)]||c[m]||u[m]||l;return n?t.createElement(g,i(i({ref:a},y),{},{components:n})):t.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var l=n.length,i=new Array(l);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>u,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",sidebar_label:"ObjectFanoutAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectFanoutAnalysis",id:"api/classes/heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",sidebar_label:"ObjectFanoutAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},next:{title:"ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectFanoutAnalysis()',id:"new-objectfanoutanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function u(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectFanoutAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectfanoutanalysis"},(0,s.yg)("a",{id:"new objectfanoutanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectFanoutAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/heap-analysis/src/plugins/ObjectFanoutAnalysis.ts#L22"},"heap-analysis/src/plugins/ObjectFanoutAnalysis.ts:22"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[233],{5680:(e,a,n)=>{n.d(a,{xA:()=>y,yg:()=>g});var t=n(6540);function s(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(s[n]=e[n]);return s}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}var o=t.createContext({}),p=function(e){var a=t.useContext(o),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},y=function(e){var a=p(e.components);return t.createElement(o.Provider,{value:a},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},m=t.forwardRef((function(e,a){var n=e.components,s=e.mdxType,l=e.originalType,o=e.parentName,y=r(e,["components","mdxType","originalType","parentName"]),c=p(n),m=s,g=c["".concat(o,".").concat(m)]||c[m]||u[m]||l;return n?t.createElement(g,i(i({ref:a},y),{},{components:n})):t.createElement(g,i({ref:a},y))}));function g(e,a){var n=arguments,s=a&&a.mdxType;if("string"==typeof e||s){var l=n.length,i=new Array(l);i[0]=m;var r={};for(var o in a)hasOwnProperty.call(a,o)&&(r[o]=a[o]);r.originalType=e,r[c]="string"==typeof e?e:s,i[1]=r;for(var p=2;p{n.r(a),n.d(a,{assets:()=>o,contentTitle:()=>i,default:()=>u,frontMatter:()=>l,metadata:()=>r,toc:()=>p});var t=n(8168),s=(n(6540),n(5680));const l={id:"heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",sidebar_label:"ObjectFanoutAnalysis",custom_edit_url:null},i=void 0,r={unversionedId:"api/classes/heap_analysis_src.ObjectFanoutAnalysis",id:"api/classes/heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",description:"Hierarchy",source:"@site/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis.md",sourceDirName:"api/classes",slug:"/api/classes/heap_analysis_src.ObjectFanoutAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectFanoutAnalysis",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"heap_analysis_src.ObjectFanoutAnalysis",title:"Class: ObjectFanoutAnalysis",sidebar_label:"ObjectFanoutAnalysis",custom_edit_url:null},sidebar:"sidebar",previous:{title:"GlobalVariableAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.GlobalVariableAnalysis"},next:{title:"ObjectShallowAnalysis",permalink:"/memlab/docs/api/classes/heap_analysis_src.ObjectShallowAnalysis"}},o={},p=[{value:"Hierarchy",id:"hierarchy",level:2},{value:"Constructors",id:"constructors",level:2},{value:'new ObjectFanoutAnalysis()',id:"new-objectfanoutanalysis",level:3},{value:"Methods",id:"methods",level:2},{value:'analyzeSnapshotFromFile(file, options?)',id:"analyzesnapshotfromfilefile-options",level:3},{value:'getCommandName()',id:"getcommandname",level:3}],y={toc:p},c="wrapper";function u(e){let{components:a,...n}=e;return(0,s.yg)(c,(0,t.A)({},y,n,{components:a,mdxType:"MDXLayout"}),(0,s.yg)("h2",{id:"hierarchy"},"Hierarchy"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("p",{parentName:"li"},(0,s.yg)("a",{parentName:"p",href:"/memlab/docs/api/classes/heap_analysis_src.BaseAnalysis"},(0,s.yg)("inlineCode",{parentName:"a"},"BaseAnalysis"))),(0,s.yg)("p",{parentName:"li"},"\u21b3 ",(0,s.yg)("strong",{parentName:"p"},(0,s.yg)("inlineCode",{parentName:"strong"},"ObjectFanoutAnalysis"))))),(0,s.yg)("h2",{id:"constructors"},"Constructors"),(0,s.yg)("h3",{id:"new-objectfanoutanalysis"},(0,s.yg)("a",{id:"new objectfanoutanalysis"}),(0,s.yg)("strong",{parentName:"h3"},"new ObjectFanoutAnalysis"),"()"),(0,s.yg)("h2",{id:"methods"},"Methods"),(0,s.yg)("h3",{id:"analyzesnapshotfromfilefile-options"},(0,s.yg)("a",{id:"analyzesnapshotfromfile"}),(0,s.yg)("strong",{parentName:"h3"},"analyzeSnapshotFromFile"),"(",(0,s.yg)("inlineCode",{parentName:"h3"},"file"),", ",(0,s.yg)("inlineCode",{parentName:"h3"},"options?"),")"),(0,s.yg)("p",null,"Run heap analysis for a single heap snapshot file"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Parameters"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"file"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the absolute path of a ",(0,s.yg)("inlineCode",{parentName:"li"},".heapsnapshot")," file."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("inlineCode",{parentName:"li"},"options"),": ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#runheapanalysisoptions"},(0,s.yg)("inlineCode",{parentName:"a"},"RunHeapAnalysisOptions"))," | optional configuration for the heap analysis run"))),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"Promise"),"<",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},(0,s.yg)("inlineCode",{parentName:"a"},"AnalyzeSnapshotResult")),">"," | this API returns ",(0,s.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/heap_analysis_src#analyzesnapshotresult"},"AnalyzeSnapshotResult"),", which contains\nthe logging file of analysis console output. Alternatively, to get more\nstructured analysis results, check out the documentation of the hosting\nheap analysis class and call the analysis-specific API to get results\nafter calling this method."),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Example"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile);\n// query analysis-specific and structured results\nconst stringPatterns = analysis.getTopDuplicatedStringsInCount();\n")),(0,s.yg)("p",null,"Additionally, you can specify a working directory to where\nthe intermediate, logging, and final output files will be dumped:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new StringAnalysis();\n// analysis console output is saved in result.analysisOutputFile\n// which is inside the specified working directory\nconst result = await analysis.analyzeSnapshotFromFile(snapshotFile, {\n // if the specified directory doesn't exist, memlab will create it\n workDir: '/tmp/your/work/dir',\n});\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/BaseAnalysis.ts#L95"},"heap-analysis/src/BaseAnalysis.ts:95"))))),(0,s.yg)("hr",null),(0,s.yg)("h3",{id:"getcommandname"},(0,s.yg)("a",{id:"getcommandname"}),(0,s.yg)("strong",{parentName:"h3"},"getCommandName"),"()"),(0,s.yg)("p",null,"Get the name of the heap analysis, which is also used to reference\nthe analysis in memlab command-line tool."),(0,s.yg)("p",null,"The following terminal command will initiate with this analysis:\n",(0,s.yg)("inlineCode",{parentName:"p"},"memlab analyze ")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Returns"),": ",(0,s.yg)("inlineCode",{parentName:"li"},"string")," | the name of the analysis"),(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Examples"),":")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-typescript"},"const analysis = new YourAnalysis();\nconst name = analysis.getCommandName();\n")),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},"Source"),":",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/heap-analysis/src/plugins/ObjectFanoutAnalysis.ts#L22"},"heap-analysis/src/plugins/ObjectFanoutAnalysis.ts:22"))))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/fc5c0a35.85c8b236.js b/assets/js/fc5c0a35.8eda2a00.js similarity index 96% rename from assets/js/fc5c0a35.85c8b236.js rename to assets/js/fc5c0a35.8eda2a00.js index d996cf1e..62950f7b 100644 --- a/assets/js/fc5c0a35.85c8b236.js +++ b/assets/js/fc5c0a35.8eda2a00.js @@ -1 +1 @@ -"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9539],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>d});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=t.createContext({}),p=function(e){var a=t.useContext(c),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},s=function(e){var a=p(e.components);return t.createElement(c.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},y=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,l=e.originalType,c=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),g=p(n),y=r,d=g["".concat(c,".").concat(y)]||g[y]||m[y]||l;return n?t.createElement(d,i(i({ref:a},s),{},{components:n})):t.createElement(d,i({ref:a},s))}));function d(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=y;var o={};for(var c in a)hasOwnProperty.call(a,c)&&(o[c]=a[c]);o.originalType=e,o[g]="string"==typeof e?e:r,i[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>c,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>o,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const l={id:"core_src.IScenario",title:"Interface: IScenario",sidebar_label:"IScenario",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.IScenario",id:"api/interfaces/core_src.IScenario",title:"Interface: IScenario",description:"Test scenario specifies how you want a E2E test to interact with a web browser.",source:"@site/docs/api/interfaces/core_src.IScenario.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IScenario",permalink:"/memlab/docs/api/interfaces/core_src.IScenario",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IScenario",title:"Interface: IScenario",sidebar_label:"IScenario",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter"}},c={},p=[{value:"Properties",id:"properties",level:2},{value:' Optional action: InteractionsCallback',id:"-optional-action-interactionscallback",level:3},{value:' Optional back: InteractionsCallback',id:"-optional-back-interactionscallback",level:3},{value:' Optional beforeInitialPageLoad: InteractionsCallback',id:"-optional-beforeinitialpageload-interactionscallback",level:3},{value:' Optional beforeLeakFilter: InitLeakFilterCallback',id:"-optional-beforeleakfilter-initleakfiltercallback",level:3},{value:' Optional isPageLoaded: CheckPageLoadCallback',id:"-optional-ispageloaded-checkpageloadcallback",level:3},{value:' Optional leakFilter: LeakFilterCallback',id:"-optional-leakfilter-leakfiltercallback",level:3},{value:' Optional retainerReferenceFilter: ReferenceFilterCallback',id:"-optional-retainerreferencefilter-referencefiltercallback",level:3},{value:' Optional setup: InteractionsCallback',id:"-optional-setup-interactionscallback",level:3},{value:"Methods",id:"methods",level:2},{value:'Optional cookies()',id:"optional-cookies",level:3},{value:'Optional repeat()',id:"optional-repeat",level:3},{value:'url()',id:"url",level:3}],s={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"Test scenario specifies how you want a E2E test to interact with a web browser.\nThe test scenario can be saved as a ",(0,r.yg)("inlineCode",{parentName:"p"},".js")," file and passed to the ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab\nrun --scenario")," command:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as test.js and use in terminal:\n// $ memlab run --scenario test.js\n\nmodule.exports = {\n url: () => 'https://www.npmjs.com/',\n action: async () => ... ,\n back: async () => ... ,\n cookies: () => ... , // optional\n repeat: () => ... , // optional\n ...\n};\n")),(0,r.yg)("p",null,"The test scenario instance can also be passed to the\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#run"},"run")," API exported by ",(0,r.yg)("inlineCode",{parentName:"p"},"@memlab/api"),"."),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const {run} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n action: async () => ... ,\n back: async () => ... ,\n cookies: () => ... , // optional\n repeat: () => ... , // optional\n ...\n };\n const leaks = await run({scenario});\n})();\n")),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-optional-action-interactionscallback"},(0,r.yg)("a",{id:"action",name:"action"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"action"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"action")," is the callback function that defines the interaction\nwhere you want to trigger memory leaks after the initial page load.\nAll JS objects in browser allocated by the browser interactions triggered\nfrom the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback will be candidates for memory leak filtering."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("p",null,"Note: always clean up external puppeteer references to JS objects\nin the browser context."),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n const elements = await page.$x(\"//button[contains(., 'Text in Button')]\");\n const [button] = elements;\n if (button) {\n await button.click();\n }\n // dispose external references to JS objects in browser context\n await promise.all(elements.map(e => e.dispose()));\n },\n back: async (page) => ... ,\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L841"},"core/src/lib/Types.ts:841"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-back-interactionscallback"},(0,r.yg)("a",{id:"back",name:"back"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"back"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"back")," is the callback function that specifies how memlab should\nback/revert the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback. Think of it as an undo action."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n")),(0,r.yg)("p",null,"Check out ",(0,r.yg)("a",{parentName:"p",href:"/docs/how-memlab-works"},"this page")," on why\nmemlab needs to undo/revert the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L867"},"core/src/lib/Types.ts:867"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-beforeinitialpageload-interactionscallback"},(0,r.yg)("a",{id:"beforeinitialpageload",name:"beforeinitialpageload"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"beforeInitialPageLoad"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"beforeInitialPageLoad")," is the callback function that will be called only\nonce before the initial page load. This callback can be used to set up\nthe HTTP headers or to prepare data before loading the web page."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n beforeInitialPageLoad: async (page) => {\n // before the initial page load\n },\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L745"},"core/src/lib/Types.ts:745"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-beforeleakfilter-initleakfiltercallback"},(0,r.yg)("a",{id:"beforeleakfilter",name:"beforeleakfilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"beforeLeakFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#initleakfiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InitLeakFilterCallback"))),(0,r.yg)("p",null,"Lifecycle function callback that is invoked initially once before\nthe subsequent ",(0,r.yg)("inlineCode",{parentName:"p"},"leakFilter")," function calls. This callback could\nbe used to initialize some data stores or to any one-off\npreprocessings."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,r.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,r.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n beforeLeakFilter: (snapshot, leakedNodeIds) {\n // initialize some data stores\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L953"},"core/src/lib/Types.ts:953"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-ispageloaded-checkpageloadcallback"},(0,r.yg)("a",{id:"ispageloaded",name:"ispageloaded"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"isPageLoaded"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#checkpageloadcallback"},(0,r.yg)("inlineCode",{parentName:"a"},"CheckPageLoadCallback"))),(0,r.yg)("p",null,"Optional callback function that checks if the web page is loaded\nfor the initial page load and subsequent browser interactions."),(0,r.yg)("p",null,"If this callback is not provided, memlab by default\nconsiders a navigation to be finished when there are no network\nconnections for at least 500ms."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": a boolean value, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),", memlab will consider\nthe navigation completes, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"false"),", memlab will keep calling\nthis callback until it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),". This is an async callback, you can\nalso ",(0,r.yg)("inlineCode",{parentName:"p"},"await")," and returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," until some async logic is resolved.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n isPageLoaded: async (page) => {\n await page.waitForNavigation({\n // consider navigation to be finished when there are\n // no more than 2 network connections for at least 500 ms.\n waitUntil: 'networkidle2',\n // Maximum navigation time in milliseconds\n timeout: 5000,\n });\n return true;\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L925"},"core/src/lib/Types.ts:925"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-leakfilter-leakfiltercallback"},(0,r.yg)("a",{id:"leakfilter",name:"leakfilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"leakFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#leakfiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"LeakFilterCallback"))),(0,r.yg)("p",null,"This callback defines how you want to filter out the\nleaked objects. The callback is called for every node (JS heap\nobject in browser) allocated by the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback, but not\nreleased after the ",(0,r.yg)("inlineCode",{parentName:"p"},"back")," callback. Those objects could be caches\nthat are retained in memory on purpose, or they are memory leaks."),(0,r.yg)("p",null,"This optional callback allows you to define your own algorithm\nto cherry pick memory leaks for specific JS program under test."),(0,r.yg)("p",null,"If this optional callback is not defined, memlab will use its\nbuilt-in leak filter, which considers detached DOM elements\nand unmounted Fiber nodes (detached from React Fiber tree) as\nmemory leaks."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode"))," | the heap object\nallocated but not released. This filter callback will be applied\nto each node allocated but not released in the heap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,r.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,r.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": the boolean value indicating whether the given node in\nthe snapshot should be considered as leaked.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n leakFilter(node, snapshot, leakedNodeIds) {\n // any unreleased node (JS heap object) with 1MB+\n // retained size is considered a memory leak\n return node.retainedSize > 1000000;\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L998"},"core/src/lib/Types.ts:998"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-retainerreferencefilter-referencefiltercallback"},(0,r.yg)("a",{id:"retainerreferencefilter",name:"retainerreferencefilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"retainerReferenceFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#referencefiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"ReferenceFilterCallback"))),(0,r.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be considered as part of the retainer trace.\nThe callback is called for every reference (edge) in the heap snapshot."),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge")," : ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"))," | the reference (edge)\nthat is considered for calcualting the retainer trace"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the heap snapshot\ntaken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default\nlogic for whether a reference should be considered as part of the\nretainer trace, if this parameter is true, it means MemLab will\nconsider this reference when calculating the retainer trace."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": the value indicating whether the given reference should be\nconsidered when calculating the retainer trace. Note that when this\ncallback returns true, the reference will only be considered as a candidate\nfor retainer trace, so it may or may not be included in the retainer trace;\nhowever, if this callback returns false, the reference will be excluded."))),(0,r.yg)("p",null,"Note that by excluding a dominator reference of an object (i.e., an edge\nthat must be traveled through to reach the heap object from GC roots),\nthe object will be considered as unreachable in the heap graph; and\ntherefore, the reference and heap object will not be included in the\nretainer trace detection and retainer size calculation."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n retainerReferenceFilter(edge, _snapshot, _leakedNodeIds) {\n // exclude react fiber references\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n return true;\n }\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L1044"},"core/src/lib/Types.ts:1044"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-setup-interactionscallback"},(0,r.yg)("a",{id:"setup",name:"setup"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"setup"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"setup")," is the callback function that will be called only once\nafter the initial page load. This callback can be used to log in\nif you have to (we recommend using ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),")\nor to prepare data before the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#action"},"action")," call."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n setup: async (page) => {\n // log in or prepare data for the interaction\n },\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L794"},"core/src/lib/Types.ts:794"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"optional-cookies"},(0,r.yg)("a",{id:"cookies"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"cookies"),"()"),(0,r.yg)("p",null,"If the page you are running memlab against requires authentication or\nspecific cookie(s) to be set, you can pass them as\na list of ",(0,r.yg)("inlineCode",{parentName:"p"},"")," tuples."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},"Note"),": please make sure that you provide the correct ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field for\nthe cookies tuples. If no ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field is specified, memlab will try\nto fill in a domain based on the ",(0,r.yg)("inlineCode",{parentName:"p"},"url")," callback.\nFor example, when the ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field is absent,\nmemlab will auto fill in ",(0,r.yg)("inlineCode",{parentName:"p"},".facebook.com")," as domain base\non the initial page load's url: ",(0,r.yg)("inlineCode",{parentName:"p"},"https://www.facebook.com/"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#cookies"},(0,r.yg)("inlineCode",{parentName:"a"},"Cookies"))," | cookie list"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.facebook.com/',\n cookies: () => [\n {name:'cm_j', value: 'none', domain: '.facebook.com'},\n {name:'datr', value: 'yJvIY...', domain: '.facebook.com'},\n {name:'c_user', value: '8917...', domain: '.facebook.com'},\n {name:'xs', value: '95:9WQ...', domain: '.facebook.com'},\n // ...\n ],\n};\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L715"},"core/src/lib/Types.ts:715"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"optional-repeat"},(0,r.yg)("a",{id:"repeat"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"repeat"),"()"),(0,r.yg)("p",null,"Specifies how many ",(0,r.yg)("strong",{parentName:"p"},"extra")," ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"back")," actions performed\nby memlab."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": a number value specifies the number of extra actions.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n // browser interaction: two additional [ action -> back ]\n // init-load -> action -> back -> action -> back -> action -> back\n repeat: () => 2,\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L886"},"core/src/lib/Types.ts:886"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"url"},(0,r.yg)("a",{id:"url"}),(0,r.yg)("strong",{parentName:"h3"},"url"),"()"),(0,r.yg)("p",null,"String value of the initial url of the page."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the string value of the initial url"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n};\n\nmodule.exports = scenario;\n")),(0,r.yg)("p",null,"If a test scenario only specifies the ",(0,r.yg)("inlineCode",{parentName:"p"},"url")," callback (without the ",(0,r.yg)("inlineCode",{parentName:"p"},"action"),"\ncallback), memlab will try to detect memory leaks from the initial page\nload. All objects allocated by the initial page load will be candidates\nfor memory leak filtering."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/0504bd4/packages/core/src/lib/Types.ts#L763"},"core/src/lib/Types.ts:763"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkmemlab_website=self.webpackChunkmemlab_website||[]).push([[9539],{5680:(e,a,n)=>{n.d(a,{xA:()=>s,yg:()=>y});var t=n(6540);function r(e,a,n){return a in e?Object.defineProperty(e,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[a]=n,e}function l(e,a){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var a=1;a=0||(r[n]=e[n]);return r}(e,a);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=t.createContext({}),p=function(e){var a=t.useContext(c),n=a;return e&&(n="function"==typeof e?e(a):i(i({},a),e)),n},s=function(e){var a=p(e.components);return t.createElement(c.Provider,{value:a},e.children)},g="mdxType",m={inlineCode:"code",wrapper:function(e){var a=e.children;return t.createElement(t.Fragment,{},a)}},d=t.forwardRef((function(e,a){var n=e.components,r=e.mdxType,l=e.originalType,c=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),g=p(n),d=r,y=g["".concat(c,".").concat(d)]||g[d]||m[d]||l;return n?t.createElement(y,i(i({ref:a},s),{},{components:n})):t.createElement(y,i({ref:a},s))}));function y(e,a){var n=arguments,r=a&&a.mdxType;if("string"==typeof e||r){var l=n.length,i=new Array(l);i[0]=d;var o={};for(var c in a)hasOwnProperty.call(a,c)&&(o[c]=a[c]);o.originalType=e,o[g]="string"==typeof e?e:r,i[1]=o;for(var p=2;p{n.r(a),n.d(a,{assets:()=>c,contentTitle:()=>i,default:()=>m,frontMatter:()=>l,metadata:()=>o,toc:()=>p});var t=n(8168),r=(n(6540),n(5680));const l={id:"core_src.IScenario",title:"Interface: IScenario",sidebar_label:"IScenario",custom_edit_url:null},i=void 0,o={unversionedId:"api/interfaces/core_src.IScenario",id:"api/interfaces/core_src.IScenario",title:"Interface: IScenario",description:"Test scenario specifies how you want a E2E test to interact with a web browser.",source:"@site/docs/api/interfaces/core_src.IScenario.md",sourceDirName:"api/interfaces",slug:"/api/interfaces/core_src.IScenario",permalink:"/memlab/docs/api/interfaces/core_src.IScenario",draft:!1,editUrl:null,tags:[],version:"current",frontMatter:{id:"core_src.IScenario",title:"Interface: IScenario",sidebar_label:"IScenario",custom_edit_url:null},sidebar:"sidebar",previous:{title:"ILeakFilter",permalink:"/memlab/docs/api/interfaces/core_src.ILeakFilter"}},c={},p=[{value:"Properties",id:"properties",level:2},{value:' Optional action: InteractionsCallback',id:"-optional-action-interactionscallback",level:3},{value:' Optional back: InteractionsCallback',id:"-optional-back-interactionscallback",level:3},{value:' Optional beforeInitialPageLoad: InteractionsCallback',id:"-optional-beforeinitialpageload-interactionscallback",level:3},{value:' Optional beforeLeakFilter: InitLeakFilterCallback',id:"-optional-beforeleakfilter-initleakfiltercallback",level:3},{value:' Optional isPageLoaded: CheckPageLoadCallback',id:"-optional-ispageloaded-checkpageloadcallback",level:3},{value:' Optional leakFilter: LeakFilterCallback',id:"-optional-leakfilter-leakfiltercallback",level:3},{value:' Optional retainerReferenceFilter: ReferenceFilterCallback',id:"-optional-retainerreferencefilter-referencefiltercallback",level:3},{value:' Optional setup: InteractionsCallback',id:"-optional-setup-interactionscallback",level:3},{value:"Methods",id:"methods",level:2},{value:'Optional cookies()',id:"optional-cookies",level:3},{value:'Optional repeat()',id:"optional-repeat",level:3},{value:'url()',id:"url",level:3}],s={toc:p},g="wrapper";function m(e){let{components:a,...n}=e;return(0,r.yg)(g,(0,t.A)({},s,n,{components:a,mdxType:"MDXLayout"}),(0,r.yg)("p",null,"Test scenario specifies how you want a E2E test to interact with a web browser.\nThe test scenario can be saved as a ",(0,r.yg)("inlineCode",{parentName:"p"},".js")," file and passed to the ",(0,r.yg)("inlineCode",{parentName:"p"},"memlab\nrun --scenario")," command:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as test.js and use in terminal:\n// $ memlab run --scenario test.js\n\nmodule.exports = {\n url: () => 'https://www.npmjs.com/',\n action: async () => ... ,\n back: async () => ... ,\n cookies: () => ... , // optional\n repeat: () => ... , // optional\n ...\n};\n")),(0,r.yg)("p",null,"The test scenario instance can also be passed to the\n",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/modules/api_src#run"},"run")," API exported by ",(0,r.yg)("inlineCode",{parentName:"p"},"@memlab/api"),"."),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const {run} = require('@memlab/api');\n\n(async function () {\n const scenario = {\n url: () => 'https://www.facebook.com',\n action: async () => ... ,\n back: async () => ... ,\n cookies: () => ... , // optional\n repeat: () => ... , // optional\n ...\n };\n const leaks = await run({scenario});\n})();\n")),(0,r.yg)("h2",{id:"properties"},"Properties"),(0,r.yg)("h3",{id:"-optional-action-interactionscallback"},(0,r.yg)("a",{id:"action",name:"action"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"action"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"action")," is the callback function that defines the interaction\nwhere you want to trigger memory leaks after the initial page load.\nAll JS objects in browser allocated by the browser interactions triggered\nfrom the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback will be candidates for memory leak filtering."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("p",null,"Note: always clean up external puppeteer references to JS objects\nin the browser context."),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n const elements = await page.$x(\"//button[contains(., 'Text in Button')]\");\n const [button] = elements;\n if (button) {\n await button.click();\n }\n // dispose external references to JS objects in browser context\n await promise.all(elements.map(e => e.dispose()));\n },\n back: async (page) => ... ,\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L841"},"core/src/lib/Types.ts:841"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-back-interactionscallback"},(0,r.yg)("a",{id:"back",name:"back"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"back"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"back")," is the callback function that specifies how memlab should\nback/revert the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback. Think of it as an undo action."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n")),(0,r.yg)("p",null,"Check out ",(0,r.yg)("a",{parentName:"p",href:"/docs/how-memlab-works"},"this page")," on why\nmemlab needs to undo/revert the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L867"},"core/src/lib/Types.ts:867"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-beforeinitialpageload-interactionscallback"},(0,r.yg)("a",{id:"beforeinitialpageload",name:"beforeinitialpageload"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"beforeInitialPageLoad"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"beforeInitialPageLoad")," is the callback function that will be called only\nonce before the initial page load. This callback can be used to set up\nthe HTTP headers or to prepare data before loading the web page."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n beforeInitialPageLoad: async (page) => {\n // before the initial page load\n },\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L745"},"core/src/lib/Types.ts:745"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-beforeleakfilter-initleakfiltercallback"},(0,r.yg)("a",{id:"beforeleakfilter",name:"beforeleakfilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"beforeLeakFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#initleakfiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InitLeakFilterCallback"))),(0,r.yg)("p",null,"Lifecycle function callback that is invoked initially once before\nthe subsequent ",(0,r.yg)("inlineCode",{parentName:"p"},"leakFilter")," function calls. This callback could\nbe used to initialize some data stores or to any one-off\npreprocessings."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,r.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,r.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n beforeLeakFilter: (snapshot, leakedNodeIds) {\n // initialize some data stores\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L953"},"core/src/lib/Types.ts:953"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-ispageloaded-checkpageloadcallback"},(0,r.yg)("a",{id:"ispageloaded",name:"ispageloaded"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"isPageLoaded"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#checkpageloadcallback"},(0,r.yg)("inlineCode",{parentName:"a"},"CheckPageLoadCallback"))),(0,r.yg)("p",null,"Optional callback function that checks if the web page is loaded\nfor the initial page load and subsequent browser interactions."),(0,r.yg)("p",null,"If this callback is not provided, memlab by default\nconsiders a navigation to be finished when there are no network\nconnections for at least 500ms."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": a boolean value, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),", memlab will consider\nthe navigation completes, if it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"false"),", memlab will keep calling\nthis callback until it returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true"),". This is an async callback, you can\nalso ",(0,r.yg)("inlineCode",{parentName:"p"},"await")," and returns ",(0,r.yg)("inlineCode",{parentName:"p"},"true")," until some async logic is resolved.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n isPageLoaded: async (page) => {\n await page.waitForNavigation({\n // consider navigation to be finished when there are\n // no more than 2 network connections for at least 500 ms.\n waitUntil: 'networkidle2',\n // Maximum navigation time in milliseconds\n timeout: 5000,\n });\n return true;\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L925"},"core/src/lib/Types.ts:925"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-leakfilter-leakfiltercallback"},(0,r.yg)("a",{id:"leakfilter",name:"leakfilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"leakFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#leakfiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"LeakFilterCallback"))),(0,r.yg)("p",null,"This callback defines how you want to filter out the\nleaked objects. The callback is called for every node (JS heap\nobject in browser) allocated by the ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," callback, but not\nreleased after the ",(0,r.yg)("inlineCode",{parentName:"p"},"back")," callback. Those objects could be caches\nthat are retained in memory on purpose, or they are memory leaks."),(0,r.yg)("p",null,"This optional callback allows you to define your own algorithm\nto cherry pick memory leaks for specific JS program under test."),(0,r.yg)("p",null,"If this optional callback is not defined, memlab will use its\nbuilt-in leak filter, which considers detached DOM elements\nand unmounted Fiber nodes (detached from React Fiber tree) as\nmemory leaks."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"node"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapNode"},"IHeapNode"))," | the heap object\nallocated but not released. This filter callback will be applied\nto each node allocated but not released in the heap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the final heap\nsnapshot taken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"leakedNodeIds"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"Set")," | the set of ids of all JS heap objects\nallocated by the ",(0,r.yg)("inlineCode",{parentName:"li"},"action")," call but not released after the ",(0,r.yg)("inlineCode",{parentName:"li"},"back")," call\nin browser."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": the boolean value indicating whether the given node in\nthe snapshot should be considered as leaked.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n leakFilter(node, snapshot, leakedNodeIds) {\n // any unreleased node (JS heap object) with 1MB+\n // retained size is considered a memory leak\n return node.retainedSize > 1000000;\n },\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L998"},"core/src/lib/Types.ts:998"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-retainerreferencefilter-referencefiltercallback"},(0,r.yg)("a",{id:"retainerreferencefilter",name:"retainerreferencefilter"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"retainerReferenceFilter"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#referencefiltercallback"},(0,r.yg)("inlineCode",{parentName:"a"},"ReferenceFilterCallback"))),(0,r.yg)("p",null,"Callback that can be used to define a logic to decide whether\na reference should be considered as part of the retainer trace.\nThe callback is called for every reference (edge) in the heap snapshot."),(0,r.yg)("p",null,"For concrete examples, check out ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#leakfilter"},"leakFilter"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"edge")," : ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapEdge"},"IHeapEdge"))," | the reference (edge)\nthat is considered for calcualting the retainer trace"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"snapshot"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot"))," | the heap snapshot\ntaken after all browser interactions are done.\nCheck out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/interfaces/core_src.IHeapSnapshot"},"IHeapSnapshot")," for more APIs that queries the\nheap snapshot."),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"isReferenceUsedByDefault"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"boolean")," | MemLab has its own default\nlogic for whether a reference should be considered as part of the\nretainer trace, if this parameter is true, it means MemLab will\nconsider this reference when calculating the retainer trace."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": the value indicating whether the given reference should be\nconsidered when calculating the retainer trace. Note that when this\ncallback returns true, the reference will only be considered as a candidate\nfor retainer trace, so it may or may not be included in the retainer trace;\nhowever, if this callback returns false, the reference will be excluded."))),(0,r.yg)("p",null,"Note that by excluding a dominator reference of an object (i.e., an edge\nthat must be traveled through to reach the heap object from GC roots),\nthe object will be considered as unreachable in the heap graph; and\ntherefore, the reference and heap object will not be included in the\nretainer trace detection and retainer size calculation."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-javascript"},"// save as leak-filter.js\nmodule.exports = {\n retainerReferenceFilter(edge, _snapshot, _leakedNodeIds) {\n // exclude react fiber references\n if (edge.name_or_index.toString().startsWith('__reactFiber$')) {\n return false;\n }\n return true;\n }\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L1044"},"core/src/lib/Types.ts:1044"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"-optional-setup-interactionscallback"},(0,r.yg)("a",{id:"setup",name:"setup"})," ",(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"setup"),": ",(0,r.yg)("a",{parentName:"h3",href:"/memlab/docs/api/modules/core_src#interactionscallback"},(0,r.yg)("inlineCode",{parentName:"a"},"InteractionsCallback"))),(0,r.yg)("p",null,(0,r.yg)("inlineCode",{parentName:"p"},"setup")," is the callback function that will be called only once\nafter the initial page load. This callback can be used to log in\nif you have to (we recommend using ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#cookies"},"cookies"),")\nor to prepare data before the ",(0,r.yg)("a",{parentName:"p",href:"/memlab/docs/api/interfaces/core_src.IScenario#action"},"action")," call."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Parameters"),":"),(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"page"),": ",(0,r.yg)("code",null,(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"))," | the puppeteer\n",(0,r.yg)("a",{parentName:"li",href:"https://pptr.dev/api/puppeteer.page"},(0,r.yg)("inlineCode",{parentName:"a"},"Page")),"\nobject, which provides APIs to interact with the web browser. To import\nthis type, check out ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#page"},"Page"),"."))),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n setup: async (page) => {\n // log in or prepare data for the interaction\n },\n action: async (page) => {\n await page.click('a[href=\"/link\"]');\n },\n back: async (page) => {\n await page.click('a[href=\"/back\"]');\n },\n}\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L794"},"core/src/lib/Types.ts:794"))))),(0,r.yg)("h2",{id:"methods"},"Methods"),(0,r.yg)("h3",{id:"optional-cookies"},(0,r.yg)("a",{id:"cookies"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"cookies"),"()"),(0,r.yg)("p",null,"If the page you are running memlab against requires authentication or\nspecific cookie(s) to be set, you can pass them as\na list of ",(0,r.yg)("inlineCode",{parentName:"p"},"")," tuples."),(0,r.yg)("p",null,(0,r.yg)("strong",{parentName:"p"},"Note"),": please make sure that you provide the correct ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field for\nthe cookies tuples. If no ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field is specified, memlab will try\nto fill in a domain based on the ",(0,r.yg)("inlineCode",{parentName:"p"},"url")," callback.\nFor example, when the ",(0,r.yg)("inlineCode",{parentName:"p"},"domain")," field is absent,\nmemlab will auto fill in ",(0,r.yg)("inlineCode",{parentName:"p"},".facebook.com")," as domain base\non the initial page load's url: ",(0,r.yg)("inlineCode",{parentName:"p"},"https://www.facebook.com/"),"."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("a",{parentName:"li",href:"/memlab/docs/api/modules/core_src#cookies"},(0,r.yg)("inlineCode",{parentName:"a"},"Cookies"))," | cookie list"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.facebook.com/',\n cookies: () => [\n {name:'cm_j', value: 'none', domain: '.facebook.com'},\n {name:'datr', value: 'yJvIY...', domain: '.facebook.com'},\n {name:'c_user', value: '8917...', domain: '.facebook.com'},\n {name:'xs', value: '95:9WQ...', domain: '.facebook.com'},\n // ...\n ],\n};\n\nmodule.exports = scenario;\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L715"},"core/src/lib/Types.ts:715"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"optional-repeat"},(0,r.yg)("a",{id:"repeat"}),(0,r.yg)("inlineCode",{parentName:"h3"},"Optional")," ",(0,r.yg)("strong",{parentName:"h3"},"repeat"),"()"),(0,r.yg)("p",null,"Specifies how many ",(0,r.yg)("strong",{parentName:"p"},"extra")," ",(0,r.yg)("inlineCode",{parentName:"p"},"action")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"back")," actions performed\nby memlab."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Returns"),": a number value specifies the number of extra actions.")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("p",{parentName:"li"},(0,r.yg)("strong",{parentName:"p"},"Examples"),":"))),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"module.exports = {\n url: () => ... ,\n action: async (page) => ... ,\n back: async (page) => ... ,\n // browser interaction: two additional [ action -> back ]\n // init-load -> action -> back -> action -> back -> action -> back\n repeat: () => 2,\n};\n")),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"number")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L886"},"core/src/lib/Types.ts:886"))))),(0,r.yg)("hr",null),(0,r.yg)("h3",{id:"url"},(0,r.yg)("a",{id:"url"}),(0,r.yg)("strong",{parentName:"h3"},"url"),"()"),(0,r.yg)("p",null,"String value of the initial url of the page."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Returns"),": ",(0,r.yg)("inlineCode",{parentName:"li"},"string")," | the string value of the initial url"),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Examples"),":")),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"const scenario = {\n url: () => 'https://www.npmjs.com/',\n};\n\nmodule.exports = scenario;\n")),(0,r.yg)("p",null,"If a test scenario only specifies the ",(0,r.yg)("inlineCode",{parentName:"p"},"url")," callback (without the ",(0,r.yg)("inlineCode",{parentName:"p"},"action"),"\ncallback), memlab will try to detect memory leaks from the initial page\nload. All objects allocated by the initial page load will be candidates\nfor memory leak filtering."),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("strong",{parentName:"li"},"Source"),":",(0,r.yg)("ul",{parentName:"li"},(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("a",{parentName:"li",href:"https://github.com/facebook/memlab/blob/4f6de3d/packages/core/src/lib/Types.ts#L763"},"core/src/lib/Types.ts:763"))))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.9f42d73f.js b/assets/js/runtime~main.9f42d73f.js new file mode 100644 index 00000000..4b39b206 --- /dev/null +++ b/assets/js/runtime~main.9f42d73f.js @@ -0,0 +1 @@ +(()=>{"use strict";var e,a,t,f,r,b={},c={};function d(e){var a=c[e];if(void 0!==a)return a.exports;var t=c[e]={id:e,loaded:!1,exports:{}};return b[e].call(t.exports,t,t.exports,d),t.loaded=!0,t.exports}d.m=b,d.c=c,e=[],d.O=(a,t,f,r)=>{if(!t){var b=1/0;for(i=0;i=r)&&Object.keys(d.O).every((e=>d.O[e](t[o])))?t.splice(o--,1):(c=!1,r0&&e[i-1][2]>r;i--)e[i]=e[i-1];e[i]=[t,f,r]},d.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return d.d(a,{a:a}),a},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var r=Object.create(null);d.r(r);var b={};a=a||[null,t({}),t([]),t(t)];for(var c=2&f&&e;"object"==typeof c&&!~a.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((a=>b[a]=()=>e[a]));return b.default=()=>e,d.d(r,b),r},d.d=(e,a)=>{for(var t in a)d.o(a,t)&&!d.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:a[t]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((a,t)=>(d.f[t](e,a),a)),[])),d.u=e=>"assets/js/"+({211:"a3bf9775",233:"f8599c11",346:"f40f92ec",594:"5e8c322a",984:"98c9c166",1456:"c90dd339",1473:"72eddb53",1797:"2ecac66d",1901:"2a2a772b",2076:"eb14f245",2138:"1a4e3797",2522:"95206942",2625:"4527bbe9",2775:"015e0bf7",2871:"1a5ddf9d",2915:"1bb76b7a",3474:"8ea95162",3925:"b53f1d78",3976:"0e384e19",4573:"0ee6ea57",4583:"1df93b7f",4612:"5e82d739",5214:"0d63082f",5427:"226aeb7c",6061:"1f391b9e",6192:"086eefc4",6571:"26eba521",6640:"8b21a35a",6803:"3b8c55ea",7029:"a7a28a68",7130:"95f47cf5",7924:"d589d3a7",8032:"2d8affd8",8401:"17896441",8417:"27652c34",8485:"5be78946",8581:"935f2afb",8714:"1be78505",8796:"44ba4ae6",8807:"5a17db6f",8953:"e012388a",9063:"38ea947a",9439:"5b1d4bc5",9477:"3531de3b",9539:"fc5c0a35",9548:"6b5d7254",9600:"e4c6f3cc",9901:"f6f71b0f"}[e]||e)+"."+{211:"50c71145",233:"7647fd3b",346:"613fb13e",594:"21bf7920",984:"ebb42bed",1456:"f50c64ca",1473:"1a366387",1774:"f1fe53b9",1797:"327215f5",1901:"2ba7ba0e",2025:"a5ad8a15",2076:"041b5765",2138:"2f9cbdc7",2329:"e04a8183",2522:"0c281ce3",2625:"46c3ba3a",2775:"0e281620",2871:"df3df8db",2915:"ffb915e4",3474:"9192a819",3925:"11c43043",3976:"39e75d08",4573:"ed0b5255",4583:"1b4a5d7b",4612:"27534ecc",5049:"62e8de4c",5214:"c50dc84f",5427:"41805041",5491:"b7538da1",6061:"fdab0dc8",6192:"ffc16a5b",6571:"ab50ddbe",6640:"4757b023",6803:"018dbbb1",7029:"e37df510",7130:"53ed909a",7924:"4dbe711e",8032:"b192b553",8158:"45fb47a3",8401:"e6b00bc6",8417:"d0a6a2c5",8485:"84581dc3",8581:"49c1bc09",8714:"cc3d2b74",8796:"724270c1",8807:"ed14df67",8913:"811102d3",8953:"6146abb3",9063:"ea4136a3",9439:"c90c1034",9477:"8689b73f",9539:"8eda2a00",9548:"4c379e61",9600:"d050fdd8",9901:"b6bb1e52"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},r="memlab-website:",d.l=(e,a,t,b)=>{if(f[e])f[e].push(a);else{var c,o;if(void 0!==t)for(var n=document.getElementsByTagName("script"),i=0;i{c.onerror=c.onload=null,clearTimeout(s);var r=f[e];if(delete f[e],c.parentNode&&c.parentNode.removeChild(c),r&&r.forEach((e=>e(t))),a)return a(t)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=u.bind(null,c.onerror),c.onload=u.bind(null,c.onload),o&&document.head.appendChild(c)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/memlab/",d.gca=function(e){return e={17896441:"8401",95206942:"2522",a3bf9775:"211",f8599c11:"233",f40f92ec:"346","5e8c322a":"594","98c9c166":"984",c90dd339:"1456","72eddb53":"1473","2ecac66d":"1797","2a2a772b":"1901",eb14f245:"2076","1a4e3797":"2138","4527bbe9":"2625","015e0bf7":"2775","1a5ddf9d":"2871","1bb76b7a":"2915","8ea95162":"3474",b53f1d78:"3925","0e384e19":"3976","0ee6ea57":"4573","1df93b7f":"4583","5e82d739":"4612","0d63082f":"5214","226aeb7c":"5427","1f391b9e":"6061","086eefc4":"6192","26eba521":"6571","8b21a35a":"6640","3b8c55ea":"6803",a7a28a68:"7029","95f47cf5":"7130",d589d3a7:"7924","2d8affd8":"8032","27652c34":"8417","5be78946":"8485","935f2afb":"8581","1be78505":"8714","44ba4ae6":"8796","5a17db6f":"8807",e012388a:"8953","38ea947a":"9063","5b1d4bc5":"9439","3531de3b":"9477",fc5c0a35:"9539","6b5d7254":"9548",e4c6f3cc:"9600",f6f71b0f:"9901"}[e]||e,d.p+d.u(e)},(()=>{var e={5354:0,1869:0};d.f.j=(a,t)=>{var f=d.o(e,a)?e[a]:void 0;if(0!==f)if(f)t.push(f[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var r=new Promise(((t,r)=>f=e[a]=[t,r]));t.push(f[2]=r);var b=d.p+d.u(a),c=new Error;d.l(b,(t=>{if(d.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var r=t&&("load"===t.type?"missing":t.type),b=t&&t.target&&t.target.src;c.message="Loading chunk "+a+" failed.\n("+r+": "+b+")",c.name="ChunkLoadError",c.type=r,c.request=b,f[1](c)}}),"chunk-"+a,a)}},d.O.j=a=>0===e[a];var a=(a,t)=>{var f,r,b=t[0],c=t[1],o=t[2],n=0;if(b.some((a=>0!==e[a]))){for(f in c)d.o(c,f)&&(d.m[f]=c[f]);if(o)var i=o(d)}for(a&&a(t);n{"use strict";var e,a,f,t,r,d={},b={};function c(e){var a=b[e];if(void 0!==a)return a.exports;var f=b[e]={id:e,loaded:!1,exports:{}};return d[e].call(f.exports,f,f.exports,c),f.loaded=!0,f.exports}c.m=d,c.c=b,e=[],c.O=(a,f,t,r)=>{if(!f){var d=1/0;for(i=0;i=r)&&Object.keys(c.O).every((e=>c.O[e](f[o])))?f.splice(o--,1):(b=!1,r0&&e[i-1][2]>r;i--)e[i]=e[i-1];e[i]=[f,t,r]},c.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return c.d(a,{a:a}),a},f=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var r=Object.create(null);c.r(r);var d={};a=a||[null,f({}),f([]),f(f)];for(var b=2&t&&e;"object"==typeof b&&!~a.indexOf(b);b=f(b))Object.getOwnPropertyNames(b).forEach((a=>d[a]=()=>e[a]));return d.default=()=>e,c.d(r,d),r},c.d=(e,a)=>{for(var f in a)c.o(a,f)&&!c.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:a[f]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce(((a,f)=>(c.f[f](e,a),a)),[])),c.u=e=>"assets/js/"+({211:"a3bf9775",233:"f8599c11",346:"f40f92ec",594:"5e8c322a",984:"98c9c166",1456:"c90dd339",1473:"72eddb53",1797:"2ecac66d",1901:"2a2a772b",2076:"eb14f245",2138:"1a4e3797",2522:"95206942",2625:"4527bbe9",2775:"015e0bf7",2871:"1a5ddf9d",2915:"1bb76b7a",3474:"8ea95162",3925:"b53f1d78",3976:"0e384e19",4573:"0ee6ea57",4583:"1df93b7f",4612:"5e82d739",5214:"0d63082f",5427:"226aeb7c",6061:"1f391b9e",6192:"086eefc4",6571:"26eba521",6640:"8b21a35a",6803:"3b8c55ea",7029:"a7a28a68",7130:"95f47cf5",7924:"d589d3a7",8032:"2d8affd8",8401:"17896441",8417:"27652c34",8485:"5be78946",8581:"935f2afb",8714:"1be78505",8796:"44ba4ae6",8807:"5a17db6f",8953:"e012388a",9063:"38ea947a",9439:"5b1d4bc5",9477:"3531de3b",9539:"fc5c0a35",9548:"6b5d7254",9600:"e4c6f3cc",9901:"f6f71b0f"}[e]||e)+"."+{211:"50c71145",233:"c0c9117e",346:"840cd345",594:"21bf7920",984:"cac6eee1",1456:"bc9326e4",1473:"8615eb0d",1774:"f1fe53b9",1797:"f5f0f42b",1901:"2ba7ba0e",2025:"a5ad8a15",2076:"041b5765",2138:"2f9cbdc7",2329:"e04a8183",2522:"2869ba06",2625:"81ee2013",2775:"13851d34",2871:"df3df8db",2915:"6e511fc9",3474:"9192a819",3925:"2c145d5a",3976:"39e75d08",4573:"e5e89145",4583:"1b4a5d7b",4612:"27534ecc",5049:"62e8de4c",5214:"cd21904c",5427:"41805041",5491:"b7538da1",6061:"fdab0dc8",6192:"837908c5",6571:"ce8dcbb8",6640:"7de6fb63",6803:"018dbbb1",7029:"e37df510",7130:"7e757fda",7924:"4dbe711e",8032:"faed0bb1",8158:"45fb47a3",8401:"e6b00bc6",8417:"5e2cc3fe",8485:"b2dc5a65",8581:"49c1bc09",8714:"cc3d2b74",8796:"724270c1",8807:"1d864fde",8913:"811102d3",8953:"1d2da296",9063:"ea4136a3",9439:"6137fd8c",9477:"3c9fc781",9539:"85c8b236",9548:"1a2b0df8",9600:"14f34b89",9901:"b6bb1e52"}[e]+".js",c.miniCssF=e=>{},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),t={},r="memlab-website:",c.l=(e,a,f,d)=>{if(t[e])t[e].push(a);else{var b,o;if(void 0!==f)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var r=t[e];if(delete t[e],b.parentNode&&b.parentNode.removeChild(b),r&&r.forEach((e=>e(f))),a)return a(f)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=u.bind(null,b.onerror),b.onload=u.bind(null,b.onload),o&&document.head.appendChild(b)}},c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.p="/memlab/",c.gca=function(e){return e={17896441:"8401",95206942:"2522",a3bf9775:"211",f8599c11:"233",f40f92ec:"346","5e8c322a":"594","98c9c166":"984",c90dd339:"1456","72eddb53":"1473","2ecac66d":"1797","2a2a772b":"1901",eb14f245:"2076","1a4e3797":"2138","4527bbe9":"2625","015e0bf7":"2775","1a5ddf9d":"2871","1bb76b7a":"2915","8ea95162":"3474",b53f1d78:"3925","0e384e19":"3976","0ee6ea57":"4573","1df93b7f":"4583","5e82d739":"4612","0d63082f":"5214","226aeb7c":"5427","1f391b9e":"6061","086eefc4":"6192","26eba521":"6571","8b21a35a":"6640","3b8c55ea":"6803",a7a28a68:"7029","95f47cf5":"7130",d589d3a7:"7924","2d8affd8":"8032","27652c34":"8417","5be78946":"8485","935f2afb":"8581","1be78505":"8714","44ba4ae6":"8796","5a17db6f":"8807",e012388a:"8953","38ea947a":"9063","5b1d4bc5":"9439","3531de3b":"9477",fc5c0a35:"9539","6b5d7254":"9548",e4c6f3cc:"9600",f6f71b0f:"9901"}[e]||e,c.p+c.u(e)},(()=>{var e={5354:0,1869:0};c.f.j=(a,f)=>{var t=c.o(e,a)?e[a]:void 0;if(0!==t)if(t)f.push(t[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var r=new Promise(((f,r)=>t=e[a]=[f,r]));f.push(t[2]=r);var d=c.p+c.u(a),b=new Error;c.l(d,(f=>{if(c.o(e,a)&&(0!==(t=e[a])&&(e[a]=void 0),t)){var r=f&&("load"===f.type?"missing":f.type),d=f&&f.target&&f.target.src;b.message="Loading chunk "+a+" failed.\n("+r+": "+d+")",b.name="ChunkLoadError",b.type=r,b.request=d,t[1](b)}}),"chunk-"+a,a)}},c.O.j=a=>0===e[a];var a=(a,f)=>{var t,r,d=f[0],b=f[1],o=f[2],n=0;if(d.some((a=>0!==e[a]))){for(t in b)c.o(b,t)&&(c.m[t]=b[t]);if(o)var i=o(c)}for(a&&a(f);n Class: BrowserInteractionResultReader | memlab - +

Class: BrowserInteractionResultReader

A utility entity to read all generated files from the directory holding the data and results from the -last MemLab browser interaction run

Hierarchy

  • default

    BrowserInteractionResultReader

Methods

cleanup()

clean up data/files generated from the memlab browser interaction run

  • Returns: void | no return value
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// delete all data/files generated by takeSnapshots
result.cleanup();
})();

getConsoleBackupFile()

This method gets the backup file of the console output.

The memlab CLI commands (e.g., memlab find-leaks) outputs a +last MemLab browser interaction run

Hierarchy

  • default

    BrowserInteractionResultReader

Methods

cleanup()

clean up data/files generated from the memlab browser interaction run

  • Returns: void | no return value
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// delete all data/files generated by takeSnapshots
result.cleanup();
})();

getConsoleBackupFile()

This method gets the backup file of the console output.

The memlab CLI commands (e.g., memlab find-leaks) outputs a non-structured string representation for easy reading, while the APIs (e.g., findLeaks) return structured leaks representation that is handy for post-processing. If you need to obtain all the string output from the CLI in the current working directory, -you can read them from the CLI output backup file returned by this method.

  • Returns: string | the absolute path of the backup file
  • Examples:
const {takeSnapshots, findLeaks} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});
const leaks = await findLeaks(result);

// get the console output backup file
const consoleBackupFile = result.getConsoleBackupFile();
})();

getInteractionSteps()

browser interaction step sequence

  • Returns: E2EStepInfo[] | an array of browser interaction step information
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

const steps = result.getInteractionSteps();
// print each browser interaction's name and JavaScript heap size (in bytes)
steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))
})();

getRootDirectory()

get the directory where the data and generated files of -the memlab run were stored

  • Returns: string | absolute path of the directory
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get the directory that stores all the files
// generated from the takeSnapshots call
const dataDir = result.getRootDirectory();
})();

getRunMetaInfo()

general meta data of the browser interaction run

  • Returns: RunMetaInfo | meta data about the entire browser interaction
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

const metaInfo = result.getRunMetaInfo();
// print all browser web console output
console.log(metaInfo.browserInfo._consoleMessages.join('\n'));
})();

getSnapshotFileDir()

get the directory holding all snapshot files

  • Returns: string | the absolute path of the directory
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get the absolute path the directory holding all snapshot files
const files = result.getSnapshotFileDir();
})();

getSnapshotFiles()

get all snapshot files generated from last memlab browser interaction

  • Returns: string[] | an array of snapshot file's absolute path
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get absolute paths of all snapshot files
const files = result.getSnapshotFiles();
})();

Static from(workDir?)

build a result reader from a data directory where the data -and generated files of a memlab run were stored

const {BrowserInteractionResultReader} = require('@memlab/api');

const dataDir = '/tmp/memlab'; // where the last memlab run stores results
const reader = BrowserInteractionResultReader.from(dataDir);
reader.cleanup(); // clean up the results
  • Hierarchy
  • Methods
    • cleanup()
    • getConsoleBackupFile()
    • getInteractionSteps()
    • getRootDirectory()
    • getRunMetaInfo()
    • getSnapshotFileDir()
    • getSnapshotFiles()
    • Static from(workDir?)
  • Hierarchy
  • Methods
    • cleanup()
    • getConsoleBackupFile()
    • getInteractionSteps()
    • getRootDirectory()
    • getRunMetaInfo()
    • getSnapshotFileDir()
    • getSnapshotFiles()
    • Static from(workDir?)
- + \ No newline at end of file diff --git a/docs/api/classes/api_src.SnapshotResultReader/index.html b/docs/api/classes/api_src.SnapshotResultReader/index.html index 52a335c2..0c89f024 100644 --- a/docs/api/classes/api_src.SnapshotResultReader/index.html +++ b/docs/api/classes/api_src.SnapshotResultReader/index.html @@ -10,7 +10,7 @@ Class: SnapshotResultReader | memlab - + @@ -24,11 +24,11 @@ APIs (e.g., findLeaks) return structured leaks representation that is handy for post-processing. If you need to obtain all the string output from the CLI in the current working directory, -you can read them from the CLI output backup file returned by this method.

  • Returns: string | the absolute path of the backup file
  • Examples:
const {takeSnapshots, findLeaks} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});
const leaks = await findLeaks(result);

// get the console output backup file
const consoleBackupFile = result.getConsoleBackupFile();
})();

getInteractionSteps()

browser interaction step sequence

  • Returns: E2EStepInfo[] | an array of browser interaction step information

  • Examples:

const {SnapshotResultReader} = require('@memlab/api');

// baseline, target, and final are file paths of heap snapshot files
const reader = SnapshotResultReader.fromSnapshots(baseline, target, final);
const paths = reader.getInteractionSteps();

getRootDirectory()

get the directory where the data and generated files of -the memlab run were stored

  • Returns: string | absolute path of the directory
  • Examples:
const {takeSnapshots} = require('@memlab/api');

(async function () {
const scenario = { url: () => 'https://www.npmjs.com'};
const result = await takeSnapshots({scenario});

// get the directory that stores all the files
// generated from the takeSnapshots call
const dataDir = result.getRootDirectory();
})();

getSnapshotFiles()

get all snapshot files related to this SnapshotResultReader

  • Returns: string[] | an array of snapshot file's absolute path

  • Examples:

const {SnapshotResultReader} = require('@memlab/api');

// baseline, target, and final are file paths of heap snapshot files
const reader = SnapshotResultReader.fromSnapshots(baseline, target, final);
const paths = reader.getSnapshotFiles();

Static fromSnapshots(baselineSnapshot, targetSnapshot, finalSnapshot)

Build a result reader from baseline, target, and final heap snapshot files. -The three snapshot files do not have to be in the same directory.

  • Parameters:

    • baselineSnapshot: string | file path of the baseline heap snapshot
    • targetSnapshot: string | file path of the target heap snapshot
    • finalSnapshot: string | file path of the final heap snapshot
  • Returns: SnapshotResultReader | the ResultReader instance

  • Examples:

const {SnapshotResultReader, findLeaks} = require('@memlab/api');

// baseline, target, and final are file paths of heap snapshot files
const reader = SnapshotResultReader.fromSnapshots(baseline, target, final);
const leaks = await findLeaks(reader);
  • Hierarchy
  • Methods
    • getConsoleBackupFile()
    • getInteractionSteps()
    • getRootDirectory()
    • getSnapshotFiles()
    • Static fromSnapshots(baselineSnapshot, targetSnapshot, finalSnapshot)