@memlab/core 1.1.6 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/__tests__/parser/HeapParser.test.d.ts +1 -1
  2. package/dist/__tests__/parser/HeapParser.test.js +3 -3
  3. package/dist/__tests__/parser/NodeHeap.test.d.ts +1 -1
  4. package/dist/__tests__/parser/NodeHeap.test.js +6 -6
  5. package/dist/__tests__/parser/StringNode.test.d.ts +1 -1
  6. package/dist/__tests__/parser/StringNode.test.js +2 -2
  7. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +1 -1
  8. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +3 -3
  9. package/dist/__tests__/utils/utils.test.d.ts +1 -1
  10. package/dist/__tests__/utils/utils.test.js +1 -1
  11. package/dist/index.d.ts +4 -2
  12. package/dist/index.js +6 -3
  13. package/dist/lib/BaseOption.d.ts +1 -1
  14. package/dist/lib/BaseOption.js +1 -1
  15. package/dist/lib/BrowserInfo.d.ts +1 -1
  16. package/dist/lib/BrowserInfo.js +1 -1
  17. package/dist/lib/Config.d.ts +8 -2
  18. package/dist/lib/Config.js +23 -12
  19. package/dist/lib/Console.d.ts +1 -1
  20. package/dist/lib/Console.js +1 -1
  21. package/dist/lib/Constant.d.ts +1 -1
  22. package/dist/lib/Constant.js +1 -1
  23. package/dist/lib/FileManager.d.ts +1 -1
  24. package/dist/lib/FileManager.js +5 -3
  25. package/dist/lib/HeapAnalyzer.d.ts +9 -1
  26. package/dist/lib/HeapAnalyzer.js +51 -9
  27. package/dist/lib/HeapParser.d.ts +2 -2
  28. package/dist/lib/HeapParser.js +2 -2
  29. package/dist/lib/InternalValueSetter.d.ts +1 -1
  30. package/dist/lib/InternalValueSetter.js +1 -1
  31. package/dist/lib/NodeHeap.d.ts +35 -12
  32. package/dist/lib/NodeHeap.js +55 -24
  33. package/dist/lib/PackageInfoLoader.js +1 -1
  34. package/dist/lib/ProcessManager.d.ts +1 -1
  35. package/dist/lib/ProcessManager.js +1 -1
  36. package/dist/lib/Serializer.d.ts +1 -1
  37. package/dist/lib/Serializer.js +1 -1
  38. package/dist/lib/StringLoader.d.ts +2 -2
  39. package/dist/lib/StringLoader.js +2 -2
  40. package/dist/lib/Types.d.ts +51 -33
  41. package/dist/lib/Types.js +1 -1
  42. package/dist/lib/Utils.d.ts +3 -1
  43. package/dist/lib/Utils.js +71 -33
  44. package/dist/lib/heap-data/HeapEdge.d.ts +2 -2
  45. package/dist/lib/heap-data/HeapEdge.js +2 -2
  46. package/dist/lib/heap-data/HeapLocation.d.ts +2 -2
  47. package/dist/lib/heap-data/HeapLocation.js +2 -2
  48. package/dist/lib/heap-data/HeapNode.d.ts +3 -2
  49. package/dist/lib/heap-data/HeapNode.js +6 -2
  50. package/dist/lib/heap-data/HeapSnapshot.d.ts +3 -2
  51. package/dist/lib/heap-data/HeapSnapshot.js +6 -33
  52. package/dist/lib/heap-data/HeapStringNode.d.ts +2 -2
  53. package/dist/lib/heap-data/HeapStringNode.js +4 -2
  54. package/dist/lib/heap-data/HeapUtils.d.ts +2 -2
  55. package/dist/lib/heap-data/HeapUtils.js +2 -2
  56. package/dist/lib/heap-data/MemLabTagStore.d.ts +23 -0
  57. package/dist/lib/heap-data/MemLabTagStore.js +110 -0
  58. package/dist/lib/leak-filters/BaseLeakFilter.rule.d.ts +1 -1
  59. package/dist/lib/leak-filters/BaseLeakFilter.rule.js +1 -1
  60. package/dist/lib/leak-filters/LeakFilterRuleList.d.ts +1 -1
  61. package/dist/lib/leak-filters/LeakFilterRuleList.js +1 -1
  62. package/dist/lib/leak-filters/LeakObjectFilter.d.ts +1 -1
  63. package/dist/lib/leak-filters/LeakObjectFilter.js +1 -1
  64. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.d.ts +1 -1
  65. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.js +1 -1
  66. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.d.ts +1 -1
  67. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.js +1 -1
  68. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.d.ts +1 -1
  69. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.js +1 -1
  70. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.d.ts +1 -1
  71. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.js +1 -1
  72. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.d.ts +1 -1
  73. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.js +1 -1
  74. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.d.ts +1 -1
  75. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.js +1 -1
  76. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.d.ts +1 -1
  77. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.js +1 -1
  78. package/dist/logger/LeakClusterLogger.d.ts +1 -1
  79. package/dist/logger/LeakClusterLogger.js +1 -1
  80. package/dist/logger/LeakTraceDetailsLogger.d.ts +1 -1
  81. package/dist/logger/LeakTraceDetailsLogger.js +1 -1
  82. package/dist/modes/BaseMode.d.ts +1 -1
  83. package/dist/modes/BaseMode.js +1 -1
  84. package/dist/modes/InteractionTestMode.d.ts +1 -1
  85. package/dist/modes/InteractionTestMode.js +1 -1
  86. package/dist/modes/MeasureMode.d.ts +1 -1
  87. package/dist/modes/MeasureMode.js +1 -1
  88. package/dist/modes/RunningModes.d.ts +1 -1
  89. package/dist/modes/RunningModes.js +1 -1
  90. package/dist/paths/TraceFinder.d.ts +1 -1
  91. package/dist/paths/TraceFinder.js +58 -40
  92. package/dist/trace-cluster/ClusterUtils.d.ts +1 -1
  93. package/dist/trace-cluster/ClusterUtils.js +1 -1
  94. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +1 -1
  95. package/dist/trace-cluster/ClusterUtilsHelper.js +1 -1
  96. package/dist/trace-cluster/ClusteringHeuristics.d.ts +1 -1
  97. package/dist/trace-cluster/ClusteringHeuristics.js +1 -1
  98. package/dist/trace-cluster/EvalutationMetric.d.ts +1 -1
  99. package/dist/trace-cluster/EvalutationMetric.js +1 -1
  100. package/dist/trace-cluster/SequentialClustering.d.ts +17 -0
  101. package/dist/trace-cluster/SequentialClustering.js +47 -0
  102. package/dist/trace-cluster/TraceBucket.d.ts +2 -1
  103. package/dist/trace-cluster/TraceBucket.js +11 -3
  104. package/dist/trace-cluster/TraceElement.d.ts +3 -1
  105. package/dist/trace-cluster/TraceElement.js +7 -1
  106. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.d.ts +1 -1
  107. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.js +2 -2
  108. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +1 -1
  109. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +1 -1
  110. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +1 -1
  111. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +1 -1
  112. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.d.ts +1 -1
  113. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.js +1 -1
  114. package/dist/trace-cluster/strategies/machine-learning/HAC.d.ts +2 -2
  115. package/dist/trace-cluster/strategies/machine-learning/HAC.js +5 -7
  116. package/dist/trace-cluster/strategies/machine-learning/Ngram.d.ts +1 -1
  117. package/dist/trace-cluster/strategies/machine-learning/Ngram.js +1 -1
  118. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.d.ts +1 -1
  119. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.js +7 -3
  120. package/package.json +1 -1
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  'use strict';
12
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  /** @internal */
11
11
  export declare abstract class InternalValueSetter<T> {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { IHeapSnapshot } from './Types';
11
11
  /**
@@ -22,7 +22,7 @@ import type { IHeapSnapshot } from './Types';
22
22
  * * **Examples**:
23
23
  * ```typescript
24
24
  * import type {IHeapSnapshot, AnyValue} from '@memlab/core';
25
- * import {config, getNodeInnocentHeap, tagObject} from '@memlab/core';
25
+ * import {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';
26
26
  *
27
27
  * test('memory test', async () => {
28
28
  * config.muteConsole = true;
@@ -36,7 +36,7 @@ import type { IHeapSnapshot } from './Types';
36
36
  *
37
37
  * o2 = null;
38
38
  *
39
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
39
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
40
40
  *
41
41
  * // expect object with marker "memlab-mark-1" exists
42
42
  * expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
@@ -60,11 +60,11 @@ export declare function tagObject<T extends object>(o: T, tag: string): T;
60
60
  * ```typescript
61
61
  * import type {IHeapSnapshot} from '@memlab/core';
62
62
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
63
- * import {getHeapFromFile} from '@memlab/heap-analysis';
63
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
64
64
  *
65
65
  * (async function () {
66
66
  * const heapFile = dumpNodeHeapSnapshot();
67
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
67
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
68
68
  * })();
69
69
  * ```
70
70
  */
@@ -77,19 +77,42 @@ export declare function dumpNodeHeapSnapshot(): string;
77
77
  *
78
78
  * @returns heap representation without heap analysis meta data.
79
79
  *
80
- * If you need to get the heap snapshot with heap analysis meta data
81
- * use {@link dumpNodeHeapSnapshot} and {@link getHeapFromFile},
82
- * for example:
80
+ * @deprecated
81
+ * @internal
82
+ *
83
+ * If you need to get the heap snapshot with heap analysis meta data, please
84
+ * use {@link takeNodeFullHeap}.
85
+ * For example:
83
86
  * ```typescript
84
87
  * import type {IHeapSnapshot} from '@memlab/core';
85
- * import {dumpNodeHeapSnapshot} from '@memlab/core';
86
- * import {getHeapFromFile} from '@memlab/heap-analysis';
88
+ * import {takeNodeFullHeap} from '@memlab/heap-analysis';
87
89
  *
88
90
  * (async function () {
89
- * const heapFile = dumpNodeHeapSnapshot();
90
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
91
+ * const heap: IHeapSnapshot = await takeNodeFullHeap();
91
92
  * })();
92
93
  * ```
93
94
  */
94
95
  export declare function getNodeInnocentHeap(): Promise<IHeapSnapshot>;
96
+ /**
97
+ * Take a heap snapshot of the current program state
98
+ * and parse it as {@link IHeapSnapshot}. Notice that
99
+ * this API does not calculate some heap analysis meta data
100
+ * for heap analysis. But this also means faster heap parsing.
101
+ *
102
+ * @returns heap representation without heap analysis meta data.
103
+ *
104
+ * * **Examples:**
105
+ * ```typescript
106
+ * import type {IHeapSnapshot} from '@memlab/core';
107
+ * import {takeNodeMinimalHeap} from '@memlab/core';
108
+ *
109
+ * (async function () {
110
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
111
+ * })();
112
+ * ```
113
+ *
114
+ * If you need to get the heap snapshot with heap analysis meta data, please
115
+ * use {@link getFullHeapFromFile}.
116
+ */
117
+ export declare function takeNodeMinimalHeap(): Promise<IHeapSnapshot>;
95
118
  //# sourceMappingURL=NodeHeap.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -21,18 +21,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
21
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.tagObject = void 0;
24
+ exports.takeNodeMinimalHeap = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.tagObject = void 0;
25
25
  const fs_extra_1 = __importDefault(require("fs-extra"));
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const v8_1 = __importDefault(require("v8"));
28
28
  const FileManager_1 = __importDefault(require("./FileManager"));
29
29
  const Utils_1 = __importDefault(require("./Utils"));
30
- class MemLabTaggedStore {
31
- constructor() {
32
- this.taggedObjects = Object.create(null);
33
- }
34
- }
35
- const store = new MemLabTaggedStore();
30
+ const MemLabTagStore_1 = __importDefault(require("./heap-data/MemLabTagStore"));
36
31
  /**
37
32
  * Tags a string marker to an object instance, which can later be checked by
38
33
  * {@link hasObjectWithTag}. This API does not modify the object instance in
@@ -47,7 +42,7 @@ const store = new MemLabTaggedStore();
47
42
  * * **Examples**:
48
43
  * ```typescript
49
44
  * import type {IHeapSnapshot, AnyValue} from '@memlab/core';
50
- * import {config, getNodeInnocentHeap, tagObject} from '@memlab/core';
45
+ * import {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';
51
46
  *
52
47
  * test('memory test', async () => {
53
48
  * config.muteConsole = true;
@@ -61,7 +56,7 @@ const store = new MemLabTaggedStore();
61
56
  *
62
57
  * o2 = null;
63
58
  *
64
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
59
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
65
60
  *
66
61
  * // expect object with marker "memlab-mark-1" exists
67
62
  * expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
@@ -73,10 +68,7 @@ const store = new MemLabTaggedStore();
73
68
  * ```
74
69
  */
75
70
  function tagObject(o, tag) {
76
- if (!store.taggedObjects[tag]) {
77
- store.taggedObjects[tag] = new WeakSet();
78
- }
79
- store.taggedObjects[tag].add(o);
71
+ MemLabTagStore_1.default.tagObject(o, tag);
80
72
  return o;
81
73
  }
82
74
  exports.tagObject = tagObject;
@@ -92,16 +84,20 @@ exports.tagObject = tagObject;
92
84
  * ```typescript
93
85
  * import type {IHeapSnapshot} from '@memlab/core';
94
86
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
95
- * import {getHeapFromFile} from '@memlab/heap-analysis';
87
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
96
88
  *
97
89
  * (async function () {
98
90
  * const heapFile = dumpNodeHeapSnapshot();
99
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
91
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
100
92
  * })();
101
93
  * ```
102
94
  */
103
95
  function dumpNodeHeapSnapshot() {
104
- const file = path_1.default.join(FileManager_1.default.generateTmpHeapDir(), `nodejs.heapsnapshot`);
96
+ const randomID = `Math.random()`.replace('0.', '');
97
+ const file = path_1.default.join(FileManager_1.default.generateTmpHeapDir(), `nodejs-${randomID}.heapsnapshot`);
98
+ if (fs_extra_1.default.existsSync(file)) {
99
+ fs_extra_1.default.removeSync(file);
100
+ }
105
101
  v8_1.default.writeHeapSnapshot(file);
106
102
  return file;
107
103
  }
@@ -114,17 +110,18 @@ exports.dumpNodeHeapSnapshot = dumpNodeHeapSnapshot;
114
110
  *
115
111
  * @returns heap representation without heap analysis meta data.
116
112
  *
117
- * If you need to get the heap snapshot with heap analysis meta data
118
- * use {@link dumpNodeHeapSnapshot} and {@link getHeapFromFile},
119
- * for example:
113
+ * @deprecated
114
+ * @internal
115
+ *
116
+ * If you need to get the heap snapshot with heap analysis meta data, please
117
+ * use {@link takeNodeFullHeap}.
118
+ * For example:
120
119
  * ```typescript
121
120
  * import type {IHeapSnapshot} from '@memlab/core';
122
- * import {dumpNodeHeapSnapshot} from '@memlab/core';
123
- * import {getHeapFromFile} from '@memlab/heap-analysis';
121
+ * import {takeNodeFullHeap} from '@memlab/heap-analysis';
124
122
  *
125
123
  * (async function () {
126
- * const heapFile = dumpNodeHeapSnapshot();
127
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
124
+ * const heap: IHeapSnapshot = await takeNodeFullHeap();
128
125
  * })();
129
126
  * ```
130
127
  */
@@ -141,3 +138,37 @@ function getNodeInnocentHeap() {
141
138
  });
142
139
  }
143
140
  exports.getNodeInnocentHeap = getNodeInnocentHeap;
141
+ /**
142
+ * Take a heap snapshot of the current program state
143
+ * and parse it as {@link IHeapSnapshot}. Notice that
144
+ * this API does not calculate some heap analysis meta data
145
+ * for heap analysis. But this also means faster heap parsing.
146
+ *
147
+ * @returns heap representation without heap analysis meta data.
148
+ *
149
+ * * **Examples:**
150
+ * ```typescript
151
+ * import type {IHeapSnapshot} from '@memlab/core';
152
+ * import {takeNodeMinimalHeap} from '@memlab/core';
153
+ *
154
+ * (async function () {
155
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
156
+ * })();
157
+ * ```
158
+ *
159
+ * If you need to get the heap snapshot with heap analysis meta data, please
160
+ * use {@link getFullHeapFromFile}.
161
+ */
162
+ function takeNodeMinimalHeap() {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ const file = dumpNodeHeapSnapshot();
165
+ const snapshot = yield Utils_1.default.getSnapshotFromFile(file, {
166
+ buildNodeIdIndex: true,
167
+ });
168
+ fs_extra_1.default.unlink(file, () => {
169
+ // do nothing
170
+ });
171
+ return snapshot;
172
+ });
173
+ }
174
+ exports.takeNodeMinimalHeap = takeNodeMinimalHeap;
@@ -19,8 +19,8 @@ exports.PackageInfoLoader = void 0;
19
19
  * This source code is licensed under the MIT license found in the
20
20
  * LICENSE file in the root directory of this source tree.
21
21
  *
22
- * @emails oncall+ws_labs
23
22
  * @format
23
+ * @oncall ws_labs
24
24
  */
25
25
  const fs_extra_1 = __importDefault(require("fs-extra"));
26
26
  const path_1 = __importDefault(require("path"));
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { Command, Optional } from './Types';
11
11
  declare type Options = {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import { E2EStepInfo, HeapNodeIdSet, IHeapEdge, IHeapNode, IHeapSnapshot, ISerializedInfo, LeakTracePathItem, Nullable } from './Types';
11
11
  declare type JSONifyArgs = {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  /// <reference types="node" />
12
12
  declare type ReadFileOptions = {
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import { ParsedArgs } from 'minimist';
11
11
  import type { LaunchOptions, Page } from 'puppeteer';
@@ -807,6 +807,13 @@ export declare type RunMetaInfo = {
807
807
  * {@link IHeapNode} and {@link IHeapEdge}.
808
808
  */
809
809
  export interface IHeapSnapshot {
810
+ /**
811
+ * flag indicating if the heap snapshot has included
812
+ * the post-processing meta data (e.g., shortest path to GC root,
813
+ * dominator info and retainer size etc.)
814
+ * @internal
815
+ */
816
+ isProcessed: boolean;
810
817
  /** @internal */
811
818
  snapshot: RawHeapSnapshot;
812
819
  /**
@@ -819,11 +826,11 @@ export interface IHeapSnapshot {
819
826
  * ```typescript
820
827
  * import type {IHeapSnapshot, IHeapNode} from '@memlab/core';
821
828
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
822
- * import {getHeapFromFile} from '@memlab/heap-analysis';
829
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
823
830
  *
824
831
  * (async function () {
825
832
  * const heapFile = dumpNodeHeapSnapshot();
826
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
833
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
827
834
  *
828
835
  * // get the total number of heap objects
829
836
  * heap.nodes.length;
@@ -845,11 +852,11 @@ export interface IHeapSnapshot {
845
852
  * ```typescript
846
853
  * import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';
847
854
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
848
- * import {getHeapFromFile} from '@memlab/heap-analysis';
855
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
849
856
  *
850
857
  * (async function () {
851
858
  * const heapFile = dumpNodeHeapSnapshot();
852
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
859
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
853
860
  *
854
861
  * // get the total number of heap references
855
862
  * heap.edges.length;
@@ -871,11 +878,11 @@ export interface IHeapSnapshot {
871
878
  * ```typescript
872
879
  * import type {IHeapSnapshot} from '@memlab/core';
873
880
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
874
- * import {getHeapFromFile} from '@memlab/heap-analysis';
881
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
875
882
  *
876
883
  * (async function () {
877
884
  * const heapFile = dumpNodeHeapSnapshot();
878
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
885
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
879
886
  *
880
887
  * const node = heap.getNodeById(351);
881
888
  * node?.id; // should be 351
@@ -893,7 +900,7 @@ export interface IHeapSnapshot {
893
900
  * ```typescript
894
901
  * // save as example.test.ts
895
902
  * import type {IHeapSnapshot, Nullable} from '@memlab/core';
896
- * import {config, getNodeInnocentHeap} from '@memlab/core';
903
+ * import {config, takeNodeMinimalHeap} from '@memlab/core';
897
904
  *
898
905
  * class TestObject {
899
906
  * public arr1 = [1, 2, 3];
@@ -905,7 +912,7 @@ export interface IHeapSnapshot {
905
912
  *
906
913
  * let obj: Nullable<TestObject> = new TestObject();
907
914
  * // get a heap snapshot of the current program state
908
- * let heap: IHeapSnapshot = await getNodeInnocentHeap();
915
+ * let heap: IHeapSnapshot = await takeNodeMinimalHeap();
909
916
  *
910
917
  * // call some function that may add references to obj
911
918
  * rabbitHole(obj)
@@ -913,7 +920,7 @@ export interface IHeapSnapshot {
913
920
  * expect(heap.hasObjectWithClassName('TestObject')).toBe(true);
914
921
  * obj = null;
915
922
  *
916
- * heap = await getNodeInnocentHeap();
923
+ * heap = await takeNodeMinimalHeap();
917
924
  * // if rabbitHole does not have any side effect that
918
925
  * // adds new references to obj, then obj can be GCed
919
926
  * expect(heap.hasObjectWithClassName('TestObject')).toBe(false);
@@ -932,7 +939,7 @@ export interface IHeapSnapshot {
932
939
  * * **Examples**:
933
940
  * ```typescript
934
941
  * import type {IHeapSnapshot} from '@memlab/core';
935
- * import {getNodeInnocentHeap} from '@memlab/core';
942
+ * import {takeNodeMinimalHeap} from '@memlab/core';
936
943
  *
937
944
  * class TestObject {
938
945
  * public arr1 = [1, 2, 3];
@@ -942,7 +949,7 @@ export interface IHeapSnapshot {
942
949
  * (async function () {
943
950
  * const obj = new TestObject();
944
951
  * // get a heap snapshot of the current program state
945
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
952
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
946
953
  *
947
954
  * const node = heap.getAnyObjectWithClassName('TestObject');
948
955
  * console.log(node?.name); // should be 'TestObject'
@@ -961,14 +968,14 @@ export interface IHeapSnapshot {
961
968
  * ```typescript
962
969
  * import type {IHeapSnapshot} from '@memlab/core';
963
970
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
964
- * import {getHeapFromFile} from '@memlab/heap-analysis';
971
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
965
972
  *
966
973
  * (async function () {
967
974
  * // eslint-disable-next-line @typescript-eslint/no-unused-vars
968
975
  * const object = {'memlab-test-heap-property': 'memlab-test-heap-value'};
969
976
  *
970
977
  * const heapFile = dumpNodeHeapSnapshot();
971
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
978
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
972
979
  *
973
980
  * // should be true
974
981
  * console.log(heap.hasObjectWithPropertyName('memlab-test-heap-property'));
@@ -988,7 +995,7 @@ export interface IHeapSnapshot {
988
995
  *
989
996
  * ```typescript
990
997
  * import type {IHeapSnapshot, AnyValue} from '@memlab/core';
991
- * import {config, getNodeInnocentHeap, tagObject} from '@memlab/core';
998
+ * import {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';
992
999
  *
993
1000
  * test('memory test', async () => {
994
1001
  * config.muteConsole = true;
@@ -1002,7 +1009,7 @@ export interface IHeapSnapshot {
1002
1009
  *
1003
1010
  * o2 = null;
1004
1011
  *
1005
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
1012
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
1006
1013
  *
1007
1014
  * // expect object with marker "memlab-mark-1" exists
1008
1015
  * expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
@@ -1026,16 +1033,16 @@ export interface IHeapSnapshot {
1026
1033
  * @readonly it is not recommended to modify any `IHeapLocation` instance
1027
1034
  *
1028
1035
  * * **Examples**: V8 or hermes heap snapshot can be parsed by the
1029
- * {@link getHeapFromFile} API.
1036
+ * {@link getFullHeapFromFile} API.
1030
1037
  *
1031
1038
  * ```typescript
1032
1039
  * import type {IHeapSnapshot, IHeapNode, IHeapLocation} from '@memlab/core';
1033
1040
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1034
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1041
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1035
1042
  *
1036
1043
  * (async function () {
1037
1044
  * const heapFile = dumpNodeHeapSnapshot();
1038
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1045
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1039
1046
  *
1040
1047
  * // iterate over each node (heap object)
1041
1048
  * heap.nodes.forEach((node: IHeapNode, i: number) => {
@@ -1088,16 +1095,16 @@ export interface IHeapEdgeBasic {
1088
1095
  * @readonly it is not recommended to modify any `IHeapEdge` instance
1089
1096
  *
1090
1097
  * * **Examples**: V8 or hermes heap snapshot can be parsed by the
1091
- * {@link getHeapFromFile} API.
1098
+ * {@link getFullHeapFromFile} API.
1092
1099
  *
1093
1100
  * ```typescript
1094
1101
  * import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';
1095
1102
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1096
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1103
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1097
1104
  *
1098
1105
  * (async function () {
1099
1106
  * const heapFile = dumpNodeHeapSnapshot();
1100
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1107
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1101
1108
  *
1102
1109
  * // iterate over each edge (JS reference in heap)
1103
1110
  * heap.edges.forEach((edge: IHeapEdge, i: number) => {
@@ -1151,11 +1158,11 @@ export interface IHeapEdge extends IHeapEdgeBasic {
1151
1158
  * ```typescript
1152
1159
  * import type {IHeapSnapshot, IHeapEdges} from '@memlab/core';
1153
1160
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1154
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1161
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1155
1162
  *
1156
1163
  * (async function () {
1157
1164
  * const heapFile = dumpNodeHeapSnapshot();
1158
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1165
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1159
1166
  *
1160
1167
  * const edges: IHeapEdges = heap.edges;
1161
1168
  * edges.length;
@@ -1221,7 +1228,7 @@ export interface IHeapNodeBasic {
1221
1228
  */
1222
1229
  export declare type EdgeIterationCallback = (edge: IHeapEdge) => Optional<{
1223
1230
  stop: boolean;
1224
- }>;
1231
+ }> | void;
1225
1232
  /**
1226
1233
  * An `IHeapNode` instance represents a JS heap object in a heap snapshot.
1227
1234
  * A heap snapshot is generally a graph where graph nodes are JS heap objects
@@ -1230,16 +1237,16 @@ export declare type EdgeIterationCallback = (edge: IHeapEdge) => Optional<{
1230
1237
  * @readonly it is not recommended to modify any `IHeapNode` instance
1231
1238
  *
1232
1239
  * * **Examples**: V8 or hermes heap snapshot can be parsed by the
1233
- * {@link getHeapFromFile} API.
1240
+ * {@link getFullHeapFromFile} API.
1234
1241
  *
1235
1242
  * ```typescript
1236
1243
  * import type {IHeapSnapshot, IHeapNode} from '@memlab/core';
1237
1244
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1238
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1245
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1239
1246
  *
1240
1247
  * (async function () {
1241
1248
  * const heapFile = dumpNodeHeapSnapshot();
1242
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1249
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1243
1250
  *
1244
1251
  * // iterate over each node (heap object)
1245
1252
  * heap.nodes.forEach((node: IHeapNode, i: number) => {
@@ -1294,6 +1301,11 @@ export interface IHeapNode extends IHeapNodeBasic {
1294
1301
  * object (including engine-internal, native, and JS references).
1295
1302
  */
1296
1303
  referrers: IHeapEdge[];
1304
+ /**
1305
+ * returns true if the heap node has been set an incoming edge
1306
+ * which leads to the parent node on the shortest path to GC root.
1307
+ */
1308
+ hasPathEdge: boolean;
1297
1309
  /**
1298
1310
  * The incoming edge which leads to the parent node
1299
1311
  * on the shortest path to GC root.
@@ -1538,16 +1550,16 @@ export interface IHeapNode extends IHeapNodeBasic {
1538
1550
  * @readonly it is not recommended to modify any `IHeapStringNode` instance
1539
1551
  *
1540
1552
  * * **Examples**: V8 or hermes heap snapshot can be parsed by the
1541
- * {@link getHeapFromFile} API.
1553
+ * {@link getFullHeapFromFile} API.
1542
1554
  *
1543
1555
  * ```typescript
1544
1556
  * import type {IHeapSnapshot, IHeapNode, IHeapStringNode} from '@memlab/core';
1545
1557
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1546
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1558
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1547
1559
  *
1548
1560
  * (async function () {
1549
1561
  * const heapFile = dumpNodeHeapSnapshot();
1550
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1562
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1551
1563
  *
1552
1564
  * // iterate over each node (heap object)
1553
1565
  * heap.nodes.forEach((node: IHeapNode, i: number) => {
@@ -1579,11 +1591,11 @@ export interface IHeapStringNode extends IHeapNode {
1579
1591
  * ```typescript
1580
1592
  * import type {IHeapSnapshot, IHeapNodes} from '@memlab/core';
1581
1593
  * import {dumpNodeHeapSnapshot} from '@memlab/core';
1582
- * import {getHeapFromFile} from '@memlab/heap-analysis';
1594
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
1583
1595
  *
1584
1596
  * (async function () {
1585
1597
  * const heapFile = dumpNodeHeapSnapshot();
1586
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
1598
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
1587
1599
  *
1588
1600
  * const nodes: IHeapNodes = heap.nodes;
1589
1601
  * nodes.length;
@@ -1718,5 +1730,11 @@ export interface IClusterStrategy {
1718
1730
  diffTraces: (newLeakTraces: LeakTrace[], existingLeakTraces: LeakTrace[]) => TraceDiff;
1719
1731
  }
1720
1732
  /** @internal */
1733
+ export interface IHeapConfig {
1734
+ isCliInteractiveMode: boolean;
1735
+ currentHeapFile: Optional<string>;
1736
+ currentHeap: Optional<IHeapSnapshot>;
1737
+ }
1738
+ /** @internal */
1721
1739
  export declare type ErrorWithMessage = Pick<Error, 'message'>;
1722
1740
  //# sourceMappingURL=Types.d.ts.map
package/dist/lib/Types.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { HaltOrThrowOptions } from './Types';
11
11
  import type { Browser, Page } from 'puppeteer';
@@ -22,6 +22,7 @@ declare function isEssentialEdge(nodeIndex: number, edgeType: string, rootNodeIn
22
22
  declare function isFiberNodeDeletionsEdge(edge: IHeapEdge): boolean;
23
23
  declare function isBlinkRootNode(node: IHeapNode): boolean;
24
24
  declare function isPendingActivityNode(node: IHeapNode): boolean;
25
+ declare function isDOMNodeIncomplete(node: IHeapNode): boolean;
25
26
  declare function isRootNode(node: IHeapNode, opt?: AnyOptions): boolean;
26
27
  declare function isDirectPropEdge(edge: IHeapEdge): boolean;
27
28
  declare function isReturnEdge(edge: IHeapEdge): boolean;
@@ -171,6 +172,7 @@ declare const _default: {
171
172
  isDetachedDOMNode: typeof isDetachedDOMNode;
172
173
  isDirectPropEdge: typeof isDirectPropEdge;
173
174
  isDocumentDOMTreesRoot: typeof isDocumentDOMTreesRoot;
175
+ isDOMNodeIncomplete: typeof isDOMNodeIncomplete;
174
176
  isEssentialEdge: typeof isEssentialEdge;
175
177
  isFiberNode: typeof isFiberNode;
176
178
  isFiberNodeDeletionsEdge: typeof isFiberNodeDeletionsEdge;