@memlab/heap-analysis 1.0.6 → 1.0.8
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.
- package/dist/BaseAnalysis.d.ts +1 -1
- package/dist/BaseAnalysis.js +1 -1
- package/dist/HeapAnalysisLoader.d.ts +1 -1
- package/dist/HeapAnalysisLoader.js +1 -1
- package/dist/HeapConfig.d.ts +1 -1
- package/dist/HeapConfig.js +1 -1
- package/dist/PluginUtils.d.ts +3 -1
- package/dist/PluginUtils.js +32 -1
- package/dist/__tests__/HeapAnalysis.test.d.ts +1 -1
- package/dist/__tests__/HeapAnalysis.test.js +4 -3
- package/dist/__tests__/package.test.js +5 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/options/HeapAnalysisNodeIdOption.d.ts +19 -0
- package/dist/options/HeapAnalysisNodeIdOption.js +45 -0
- package/dist/options/HeapAnalysisSnapshotDirectoryOption.d.ts +1 -1
- package/dist/options/HeapAnalysisSnapshotDirectoryOption.js +1 -1
- package/dist/options/HeapAnalysisSnapshotFileOption.d.ts +1 -1
- package/dist/options/HeapAnalysisSnapshotFileOption.js +1 -1
- package/dist/plugins/CollectionsHoldingStaleAnalysis.d.ts +1 -1
- package/dist/plugins/CollectionsHoldingStaleAnalysis.js +1 -1
- package/dist/plugins/DetachedDOMElementAnalysis.d.ts +1 -1
- package/dist/plugins/DetachedDOMElementAnalysis.js +1 -1
- package/dist/plugins/GlobalVariableAnalysis/BuiltInGlobalVariables.d.ts +2 -2
- package/dist/plugins/GlobalVariableAnalysis/BuiltInGlobalVariables.js +2 -2
- package/dist/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.d.ts +1 -1
- package/dist/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.js +1 -2
- package/dist/plugins/ObjectContentAnalysis.d.ts +29 -0
- package/dist/plugins/ObjectContentAnalysis.js +107 -0
- package/dist/plugins/ObjectFanoutAnalysis.d.ts +1 -1
- package/dist/plugins/ObjectFanoutAnalysis.js +1 -1
- package/dist/plugins/ObjectShallowAnalysis.d.ts +1 -1
- package/dist/plugins/ObjectShallowAnalysis.js +1 -1
- package/dist/plugins/ObjectShapeAnalysis.d.ts +1 -1
- package/dist/plugins/ObjectShapeAnalysis.js +1 -1
- package/dist/plugins/ObjectSizeAnalysis.d.ts +1 -1
- package/dist/plugins/ObjectSizeAnalysis.js +1 -1
- package/dist/plugins/ObjectUnboundGrowthAnalysis.d.ts +1 -1
- package/dist/plugins/ObjectUnboundGrowthAnalysis.js +1 -1
- package/dist/plugins/ShapeUnboundGrowthAnalysis.d.ts +1 -1
- package/dist/plugins/ShapeUnboundGrowthAnalysis.js +1 -1
- package/dist/plugins/StringAnalysis.d.ts +1 -1
- package/dist/plugins/StringAnalysis.js +1 -1
- package/dist/plugins/UnmountedReactFiberNodesAnalysis.d.ts +1 -1
- package/dist/plugins/UnmountedReactFiberNodesAnalysis.js +1 -1
- package/package.json +1 -1
package/dist/BaseAnalysis.d.ts
CHANGED
|
@@ -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 { AnyValue } from '@memlab/core';
|
|
11
11
|
import type { HeapAnalysisOptions } from './PluginUtils';
|
package/dist/BaseAnalysis.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
|
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); }); }
|
|
@@ -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 BaseAnalysis from './BaseAnalysis';
|
|
11
11
|
declare class HeapAnalysisLoader {
|
|
@@ -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 };
|
package/dist/HeapConfig.d.ts
CHANGED
|
@@ -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, Optional, IHeapConfig } from '@memlab/core';
|
|
11
11
|
declare class HeapConfig implements IHeapConfig {
|
package/dist/HeapConfig.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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const core_1 = require("@memlab/core");
|
package/dist/PluginUtils.d.ts
CHANGED
|
@@ -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 { ParsedArgs } from 'minimist';
|
|
11
11
|
import { IHeapSnapshot, IHeapNode, AnyOptions, IHeapEdge, Nullable, MemLabConfig } from '@memlab/core';
|
|
@@ -31,6 +31,7 @@ declare type PrintNodeOption = {
|
|
|
31
31
|
};
|
|
32
32
|
declare function printNodeListInTerminal(nodeList: IHeapNode[], options?: AnyOptions & PrintNodeOption): void;
|
|
33
33
|
declare function printReferencesInTerminal(edgeList: IHeapEdge[], options?: AnyOptions & PrintNodeOption): void;
|
|
34
|
+
declare function printReferrersInTerminal(edgeList: IHeapEdge[], options?: AnyOptions & PrintNodeOption): void;
|
|
34
35
|
declare function getObjectOutgoingEdgeCount(node: IHeapNode): number;
|
|
35
36
|
/**
|
|
36
37
|
* Get the heap snapshot file's absolute path passed to the hosting heap
|
|
@@ -331,6 +332,7 @@ declare const _default: {
|
|
|
331
332
|
getFullHeapFromFile: typeof getFullHeapFromFile;
|
|
332
333
|
printNodeListInTerminal: typeof printNodeListInTerminal;
|
|
333
334
|
printReferencesInTerminal: typeof printReferencesInTerminal;
|
|
335
|
+
printReferrersInTerminal: typeof printReferrersInTerminal;
|
|
334
336
|
snapshotMapReduce: typeof snapshotMapReduce;
|
|
335
337
|
takeNodeFullHeap: typeof takeNodeFullHeap;
|
|
336
338
|
};
|
package/dist/PluginUtils.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
|
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); }); }
|
|
@@ -164,6 +164,7 @@ function getHeapObjectString(node) {
|
|
|
164
164
|
return (`${nodeId}${type} ${shapeStr}${colon} ` +
|
|
165
165
|
`${fanout}${comma} ${bytes}${comma} ${refs}`);
|
|
166
166
|
}
|
|
167
|
+
const MAX_NUM_OF_EDGES_TO_PRINT = 50;
|
|
167
168
|
function getReferenceString(edge) {
|
|
168
169
|
const edgeName = chalk_1.default.green(edge.name_or_index);
|
|
169
170
|
const objectInfo = getHeapObjectString(edge.toNode);
|
|
@@ -172,10 +173,39 @@ function getReferenceString(edge) {
|
|
|
172
173
|
function printReferencesInTerminal(edgeList, options = {}) {
|
|
173
174
|
const dot = chalk_1.default.grey('· ');
|
|
174
175
|
const indent = options.indent || '';
|
|
176
|
+
let n = 0;
|
|
175
177
|
for (const edge of edgeList) {
|
|
178
|
+
if (!core_1.config.verbose && n >= MAX_NUM_OF_EDGES_TO_PRINT) {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
++n;
|
|
176
182
|
const refStr = getReferenceString(edge);
|
|
177
183
|
core_2.info.topLevel(`${indent}${dot}${refStr}`);
|
|
178
184
|
}
|
|
185
|
+
if (n < edgeList.length) {
|
|
186
|
+
core_2.info.lowLevel(`${edgeList.length - n} more references...`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function getReferrerString(edge) {
|
|
190
|
+
const edgeName = chalk_1.default.green(edge.name_or_index);
|
|
191
|
+
const objectInfo = getHeapObjectString(edge.fromNode);
|
|
192
|
+
return ` ${objectInfo} --${edgeName}--> `;
|
|
193
|
+
}
|
|
194
|
+
function printReferrersInTerminal(edgeList, options = {}) {
|
|
195
|
+
const dot = chalk_1.default.grey('· ');
|
|
196
|
+
const indent = options.indent || '';
|
|
197
|
+
let n = 0;
|
|
198
|
+
for (const edge of edgeList) {
|
|
199
|
+
if (!core_1.config.verbose && n >= MAX_NUM_OF_EDGES_TO_PRINT) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
++n;
|
|
203
|
+
const refStr = getReferrerString(edge);
|
|
204
|
+
core_2.info.topLevel(`${indent}${dot}${refStr}`);
|
|
205
|
+
}
|
|
206
|
+
if (n < edgeList.length) {
|
|
207
|
+
core_2.info.lowLevel(`${edgeList.length - n} more referrers...`);
|
|
208
|
+
}
|
|
179
209
|
}
|
|
180
210
|
function getObjectOutgoingEdgeCount(node) {
|
|
181
211
|
if (node.name === 'Set' || node.name === 'Map') {
|
|
@@ -588,6 +618,7 @@ exports.default = {
|
|
|
588
618
|
getFullHeapFromFile,
|
|
589
619
|
printNodeListInTerminal,
|
|
590
620
|
printReferencesInTerminal,
|
|
621
|
+
printReferrersInTerminal,
|
|
591
622
|
snapshotMapReduce,
|
|
592
623
|
takeNodeFullHeap,
|
|
593
624
|
};
|
|
@@ -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); }); }
|
|
@@ -27,10 +27,11 @@ const HeapAnalysisLoader_1 = __importDefault(require("../HeapAnalysisLoader"));
|
|
|
27
27
|
beforeEach(() => {
|
|
28
28
|
core_1.config.isTest = true;
|
|
29
29
|
});
|
|
30
|
+
const timeout = 5 * 60 * 1000;
|
|
30
31
|
test('Heap analysis modules can be loaded', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
32
|
const heapAnalysisMap = HeapAnalysisLoader_1.default.loadAllAnalysis();
|
|
32
33
|
expect(heapAnalysisMap.size).toBeGreaterThan(0);
|
|
33
|
-
}));
|
|
34
|
+
}), timeout);
|
|
34
35
|
test('takeNodeFullHeap works as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
36
|
var _a;
|
|
36
37
|
class TestClass {
|
|
@@ -46,4 +47,4 @@ test('takeNodeFullHeap works as expected', () => __awaiter(void 0, void 0, void
|
|
|
46
47
|
expect((node === null || node === void 0 ? void 0 : node.dominatorNode) != null).toBe(true);
|
|
47
48
|
const size = (_a = node === null || node === void 0 ? void 0 : node.retainedSize) !== null && _a !== void 0 ? _a : 0;
|
|
48
49
|
expect(size > 0).toBe(true);
|
|
49
|
-
}));
|
|
50
|
+
}), timeout);
|
|
@@ -14,6 +14,7 @@ const index_1 = require("../index");
|
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
core_1.config.isTest = true;
|
|
16
16
|
});
|
|
17
|
+
const timeout = 5 * 60 * 1000;
|
|
17
18
|
test('loadHeapSnapshot works as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
let called = false;
|
|
19
20
|
class ExampleAnalysis extends index_1.BaseAnalysis {
|
|
@@ -34,7 +35,7 @@ test('loadHeapSnapshot works as expected', () => __awaiter(void 0, void 0, void
|
|
|
34
35
|
const analysis = new ExampleAnalysis();
|
|
35
36
|
yield analysis.analyzeSnapshotFromFile((0, core_1.dumpNodeHeapSnapshot)());
|
|
36
37
|
expect(called).toBe(true);
|
|
37
|
-
}));
|
|
38
|
+
}), timeout);
|
|
38
39
|
test('analyzeSnapshotFromFile works as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
40
|
let called = false;
|
|
40
41
|
const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
|
|
@@ -56,12 +57,12 @@ test('analyzeSnapshotFromFile works as expected', () => __awaiter(void 0, void 0
|
|
|
56
57
|
const analysis = new ExampleAnalysis();
|
|
57
58
|
yield analysis.analyzeSnapshotFromFile(heapFile);
|
|
58
59
|
expect(called).toBe(true);
|
|
59
|
-
}));
|
|
60
|
+
}), timeout);
|
|
60
61
|
test('getFullHeapFromFile works as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
62
|
const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
|
|
62
63
|
const heap = yield (0, index_1.getFullHeapFromFile)(heapFile);
|
|
63
64
|
expect(heap.nodes.length > 0).toBe(true);
|
|
64
|
-
}));
|
|
65
|
+
}), timeout);
|
|
65
66
|
test('getDominatorNodes works as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
67
|
class TestObject {
|
|
67
68
|
}
|
|
@@ -82,4 +83,4 @@ test('getDominatorNodes works as expected', () => __awaiter(void 0, void 0, void
|
|
|
82
83
|
// get the dominator nodes
|
|
83
84
|
const dominatorIds = (0, index_1.getDominatorNodes)(new Set(nodes.map(node => node.id)), heap);
|
|
84
85
|
expect(dominatorIds.size).toBeGreaterThan(0);
|
|
85
|
-
}));
|
|
86
|
+
}), timeout);
|
package/dist/index.d.ts
CHANGED
|
@@ -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 function registerPackage(): Promise<void>;
|
package/dist/index.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
|
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); }); }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall ws_labs
|
|
9
|
+
*/
|
|
10
|
+
import type { ParsedArgs } from 'minimist';
|
|
11
|
+
import type { MemLabConfig } from '@memlab/core';
|
|
12
|
+
import { BaseOption } from '@memlab/core';
|
|
13
|
+
export default class HeapAnalysisNodeIdOption extends BaseOption {
|
|
14
|
+
getOptionName(): string;
|
|
15
|
+
getDescription(): string;
|
|
16
|
+
getExampleValues(): string[];
|
|
17
|
+
parse(config: MemLabConfig, args: ParsedArgs): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=HeapAnalysisNodeIdOption.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall ws_labs
|
|
10
|
+
*/
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const core_1 = require("@memlab/core");
|
|
22
|
+
class HeapAnalysisNodeIdOption extends core_1.BaseOption {
|
|
23
|
+
getOptionName() {
|
|
24
|
+
return 'node-id';
|
|
25
|
+
}
|
|
26
|
+
getDescription() {
|
|
27
|
+
return 'set heap node ID';
|
|
28
|
+
}
|
|
29
|
+
getExampleValues() {
|
|
30
|
+
return ['94435', '@94435'];
|
|
31
|
+
}
|
|
32
|
+
parse(config, args) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const optionName = this.getOptionName();
|
|
35
|
+
const optionValue = args[optionName];
|
|
36
|
+
if (optionValue) {
|
|
37
|
+
if (typeof optionValue === 'string' && optionValue.startsWith('@')) {
|
|
38
|
+
args[optionName] = optionValue.slice(1);
|
|
39
|
+
}
|
|
40
|
+
config.focusFiberNodeId = Number(args[optionName]);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = HeapAnalysisNodeIdOption;
|
|
@@ -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 { ParsedArgs } from 'minimist';
|
|
11
11
|
import { BaseOption, MemLabConfig } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { ParsedArgs } from 'minimist';
|
|
11
11
|
import { BaseOption, MemLabConfig } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import type { IHeapNode } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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
|
declare const _default: Set<string>;
|
|
12
12
|
export default _default;
|
|
@@ -5,9 +5,9 @@
|
|
|
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
|
-
* @lightSyntaxTransform
|
|
10
8
|
* @format
|
|
9
|
+
* @lightSyntaxTransform
|
|
10
|
+
* @oncall ws_labs
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.default = new Set([
|
|
@@ -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 { HeapAnalysisOptions } from '../../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -71,7 +71,6 @@ class GlobalVariableAnalysis extends BaseAnalysis_1.default {
|
|
|
71
71
|
}
|
|
72
72
|
/** @internal */
|
|
73
73
|
getGlobalVariables(snapshot) {
|
|
74
|
-
// rank heap objects based on fanout
|
|
75
74
|
const ret = [];
|
|
76
75
|
const processNode = (node) => {
|
|
77
76
|
if (!node.name.startsWith('Window ')) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall ws_labs
|
|
9
|
+
*/
|
|
10
|
+
import type { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
|
+
import { BaseOption } from '@memlab/core';
|
|
12
|
+
import BaseAnalysis from '../BaseAnalysis';
|
|
13
|
+
declare class GlobalVariableAnalysis extends BaseAnalysis {
|
|
14
|
+
getCommandName(): string;
|
|
15
|
+
/** @internal */
|
|
16
|
+
getDescription(): string;
|
|
17
|
+
/** @internal */
|
|
18
|
+
getOptions(): BaseOption[];
|
|
19
|
+
/** @internal */
|
|
20
|
+
process(options: HeapAnalysisOptions): Promise<void>;
|
|
21
|
+
/** @internal */
|
|
22
|
+
analyzeSnapshotsInDirectory(directory: string): Promise<void>;
|
|
23
|
+
/** @internal */
|
|
24
|
+
private getObjectProperties;
|
|
25
|
+
/** @internal */
|
|
26
|
+
private getObjectReferrerEdges;
|
|
27
|
+
}
|
|
28
|
+
export default GlobalVariableAnalysis;
|
|
29
|
+
//# sourceMappingURL=ObjectContentAnalysis.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall ws_labs
|
|
10
|
+
*/
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
25
|
+
const core_1 = require("@memlab/core");
|
|
26
|
+
const HeapAnalysisNodeIdOption_1 = __importDefault(require("../options/HeapAnalysisNodeIdOption"));
|
|
27
|
+
const HeapAnalysisSnapshotFileOption_1 = __importDefault(require("../options/HeapAnalysisSnapshotFileOption"));
|
|
28
|
+
const BaseAnalysis_1 = __importDefault(require("../BaseAnalysis"));
|
|
29
|
+
const PluginUtils_1 = __importDefault(require("../PluginUtils"));
|
|
30
|
+
class GlobalVariableAnalysis extends BaseAnalysis_1.default {
|
|
31
|
+
getCommandName() {
|
|
32
|
+
return 'object';
|
|
33
|
+
}
|
|
34
|
+
/** @internal */
|
|
35
|
+
getDescription() {
|
|
36
|
+
return 'Get properties inside an object';
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
getOptions() {
|
|
40
|
+
return [new HeapAnalysisSnapshotFileOption_1.default(), new HeapAnalysisNodeIdOption_1.default()];
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
process(options) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const snapshot = yield PluginUtils_1.default.loadHeapSnapshot(options);
|
|
46
|
+
const nodeId = core_1.config.focusFiberNodeId;
|
|
47
|
+
const node = snapshot.getNodeById(nodeId);
|
|
48
|
+
if (!node) {
|
|
49
|
+
core_1.info.error(`Object @${nodeId} is not found.`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// print object info
|
|
53
|
+
const id = chalk_1.default.grey(`@${node.id}`);
|
|
54
|
+
core_1.info.topLevel(`Heap node (${node.type}) ${id}`);
|
|
55
|
+
const name = chalk_1.default.grey(`${node.name}`);
|
|
56
|
+
core_1.info.topLevel(` name: ${name}`);
|
|
57
|
+
const numReferences = chalk_1.default.grey(`${node.edge_count}`);
|
|
58
|
+
core_1.info.topLevel(` # of references: ${numReferences}`);
|
|
59
|
+
const numReferrers = chalk_1.default.grey(`${node.referrers.length}`);
|
|
60
|
+
core_1.info.topLevel(` # of referrers: ${numReferrers}`);
|
|
61
|
+
const selfSize = chalk_1.default.grey(`${node.self_size}`);
|
|
62
|
+
core_1.info.topLevel(` shallow size: ${selfSize}`);
|
|
63
|
+
const retainedSize = chalk_1.default.grey(`${node.retainedSize}`);
|
|
64
|
+
core_1.info.topLevel(` retained size: ${retainedSize}`);
|
|
65
|
+
const dominatorNode = node.dominatorNode;
|
|
66
|
+
if (dominatorNode) {
|
|
67
|
+
const dominatorNodeId = chalk_1.default.grey(`@${dominatorNode.id}`);
|
|
68
|
+
core_1.info.topLevel(` dominator node: ${dominatorNodeId}`);
|
|
69
|
+
}
|
|
70
|
+
// print object references
|
|
71
|
+
core_1.info.topLevel('\n' + chalk_1.default.bold('REFERENCES:'));
|
|
72
|
+
let list = this.getObjectProperties(snapshot, node);
|
|
73
|
+
PluginUtils_1.default.printReferencesInTerminal(list);
|
|
74
|
+
core_1.info.topLevel('\n' + chalk_1.default.bold('REFERRERS:'));
|
|
75
|
+
// print object referrers
|
|
76
|
+
list = this.getObjectReferrerEdges(snapshot, node);
|
|
77
|
+
PluginUtils_1.default.printReferrersInTerminal(list);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** @internal */
|
|
81
|
+
analyzeSnapshotsInDirectory(directory) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
|
+
const d = directory;
|
|
85
|
+
throw core_1.utils.haltOrThrow(`${this.constructor.name} does not support analyzeSnapshotsInDirectory`);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** @internal */
|
|
89
|
+
getObjectProperties(snapshot, node) {
|
|
90
|
+
const ret = [];
|
|
91
|
+
const refs = node.references;
|
|
92
|
+
for (const edge of refs) {
|
|
93
|
+
ret.push(edge);
|
|
94
|
+
}
|
|
95
|
+
return ret;
|
|
96
|
+
}
|
|
97
|
+
/** @internal */
|
|
98
|
+
getObjectReferrerEdges(snapshot, node) {
|
|
99
|
+
const ret = [];
|
|
100
|
+
const refs = node.referrers;
|
|
101
|
+
for (const edge of refs) {
|
|
102
|
+
ret.push(edge);
|
|
103
|
+
}
|
|
104
|
+
return ret;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.default = GlobalVariableAnalysis;
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|
|
@@ -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 { HeapAnalysisOptions } from '../PluginUtils';
|
|
11
11
|
import { BaseOption } from '@memlab/core';
|
|
@@ -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); }); }
|