@memlab/heap-analysis 1.0.9 → 1.0.12

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/dist/BaseAnalysis.d.ts +1 -1
  4. package/dist/BaseAnalysis.js +1 -1
  5. package/dist/HeapAnalysisLoader.d.ts +1 -1
  6. package/dist/HeapAnalysisLoader.js +1 -1
  7. package/dist/HeapConfig.d.ts +1 -1
  8. package/dist/HeapConfig.js +1 -1
  9. package/dist/PluginUtils.d.ts +8 -2
  10. package/dist/PluginUtils.js +37 -2
  11. package/dist/__tests__/HeapAnalysis.test.d.ts +1 -1
  12. package/dist/__tests__/HeapAnalysis.test.js +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/options/HeapAnalysisNodeIdOption.d.ts +1 -1
  16. package/dist/options/HeapAnalysisNodeIdOption.js +1 -1
  17. package/dist/options/HeapAnalysisSnapshotDirectoryOption.d.ts +1 -1
  18. package/dist/options/HeapAnalysisSnapshotDirectoryOption.js +1 -1
  19. package/dist/options/HeapAnalysisSnapshotFileOption.d.ts +1 -1
  20. package/dist/options/HeapAnalysisSnapshotFileOption.js +1 -1
  21. package/dist/plugins/CollectionUnboundGrowthAnalysis.d.ts +26 -0
  22. package/dist/plugins/CollectionUnboundGrowthAnalysis.js +169 -0
  23. package/dist/plugins/CollectionsHoldingStaleAnalysis.d.ts +1 -1
  24. package/dist/plugins/CollectionsHoldingStaleAnalysis.js +1 -1
  25. package/dist/plugins/DetachedDOMElementAnalysis.d.ts +1 -1
  26. package/dist/plugins/DetachedDOMElementAnalysis.js +1 -1
  27. package/dist/plugins/GlobalVariableAnalysis/BuiltInGlobalVariables.d.ts +1 -1
  28. package/dist/plugins/GlobalVariableAnalysis/BuiltInGlobalVariables.js +1 -1
  29. package/dist/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.d.ts +1 -1
  30. package/dist/plugins/GlobalVariableAnalysis/GlobalVariableAnalysis.js +1 -1
  31. package/dist/plugins/ObjectContentAnalysis.d.ts +1 -1
  32. package/dist/plugins/ObjectContentAnalysis.js +1 -1
  33. package/dist/plugins/ObjectFanoutAnalysis.d.ts +1 -1
  34. package/dist/plugins/ObjectFanoutAnalysis.js +1 -1
  35. package/dist/plugins/ObjectShallowAnalysis.d.ts +1 -1
  36. package/dist/plugins/ObjectShallowAnalysis.js +1 -1
  37. package/dist/plugins/ObjectShapeAnalysis.d.ts +1 -1
  38. package/dist/plugins/ObjectShapeAnalysis.js +1 -1
  39. package/dist/plugins/ObjectSizeAnalysis.d.ts +1 -1
  40. package/dist/plugins/ObjectSizeAnalysis.js +1 -1
  41. package/dist/plugins/ObjectUnboundGrowthAnalysis.d.ts +1 -1
  42. package/dist/plugins/ObjectUnboundGrowthAnalysis.js +3 -2
  43. package/dist/plugins/ShapeUnboundGrowthAnalysis.d.ts +1 -1
  44. package/dist/plugins/ShapeUnboundGrowthAnalysis.js +3 -2
  45. package/dist/plugins/StringAnalysis.d.ts +1 -1
  46. package/dist/plugins/StringAnalysis.js +1 -1
  47. package/dist/plugins/UnmountedReactFiberNodesAnalysis.d.ts +1 -1
  48. package/dist/plugins/UnmountedReactFiberNodesAnalysis.js +1 -1
  49. package/package.json +6 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,5 +4,5 @@ This is the memlab heap analysis library. It contains all memlab built-in heap a
4
4
  provides a plugin interface for adding new heap analysis that can be easily added to memlab API and memlab CLI.
5
5
 
6
6
  ## Online Resources
7
- * [Official Website and Demo](https://facebookincubator.github.io/memlab)
8
- * [Documentation](https://facebookincubator.github.io/memlab/docs/intro)
7
+ * [Official Website and Demo](https://facebook.github.io/memlab)
8
+ * [Documentation](https://facebook.github.io/memlab/docs/intro)
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { AnyValue } from '@memlab/core';
11
11
  import type { HeapAnalysisOptions } from './PluginUtils';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type BaseAnalysis from './BaseAnalysis';
11
11
  declare class HeapAnalysisLoader {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IHeapSnapshot, Optional, IHeapConfig } from '@memlab/core';
11
11
  declare class HeapConfig implements IHeapConfig {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const core_1 = require("@memlab/core");
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
11
  import { IHeapSnapshot, IHeapNode, AnyOptions, IHeapEdge, Nullable, MemLabConfig } from '@memlab/core';
@@ -249,7 +249,7 @@ declare function getHeapFromFile(file: string): Promise<IHeapSnapshot>;
249
249
  * const analysis = new ExampleAnalysis();
250
250
  * // snapshotDir includes a series of .heapsnapshot files recorded by
251
251
  * // memlab or saved manually from Chrome, those files will be loaded
252
- * // in alphanumerically asceneding order
252
+ * // in alphanumerically ascending order
253
253
  * await analysis.analyzeSnapshotsInDirectory(snapshotDir);
254
254
  * ```
255
255
  * The new heap analysis can also be used with {@link analyze}, in that case
@@ -314,18 +314,24 @@ declare function aggregateDominatorMetrics(ids: Set<number>, snapshot: IHeapSnap
314
314
  */
315
315
  declare function getDominatorNodes(ids: Set<number>, snapshot: IHeapSnapshot): Set<number>;
316
316
  declare function filterOutLargestObjects(snapshot: IHeapSnapshot, objectFilter: (node: IHeapNode) => boolean, listSize?: number): IHeapNode[];
317
+ declare function calculateRetainedSizes(snapshot: IHeapSnapshot): void;
318
+ declare function isCollectObject(node: IHeapNode): boolean;
319
+ declare function getCollectionFanout(node: IHeapNode): number;
317
320
  declare const _default: {
318
321
  aggregateDominatorMetrics: typeof aggregateDominatorMetrics;
322
+ calculateRetainedSizes: typeof calculateRetainedSizes;
319
323
  defaultAnalysisArgs: {
320
324
  args: {
321
325
  _: never[];
322
326
  };
323
327
  };
324
328
  filterOutLargestObjects: typeof filterOutLargestObjects;
329
+ getCollectionFanout: typeof getCollectionFanout;
325
330
  getDominatorNodes: typeof getDominatorNodes;
326
331
  getObjectOutgoingEdgeCount: typeof getObjectOutgoingEdgeCount;
327
332
  getSnapshotDirForAnalysis: typeof getSnapshotDirForAnalysis;
328
333
  getSnapshotFileForAnalysis: typeof getSnapshotFileForAnalysis;
334
+ isCollectObject: typeof isCollectObject;
329
335
  isNodeWorthInspecting: typeof isNodeWorthInspecting;
330
336
  loadHeapSnapshot: typeof loadHeapSnapshot;
331
337
  getHeapFromFile: typeof getHeapFromFile;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -489,7 +489,7 @@ function loadProcessedSnapshot(options = {}) {
489
489
  * const analysis = new ExampleAnalysis();
490
490
  * // snapshotDir includes a series of .heapsnapshot files recorded by
491
491
  * // memlab or saved manually from Chrome, those files will be loaded
492
- * // in alphanumerically asceneding order
492
+ * // in alphanumerically ascending order
493
493
  * await analysis.analyzeSnapshotsInDirectory(snapshotDir);
494
494
  * ```
495
495
  * The new heap analysis can also be used with {@link analyze}, in that case
@@ -604,14 +604,49 @@ function filterOutLargestObjects(snapshot, objectFilter, listSize = 50) {
604
604
  });
605
605
  return largeObjects;
606
606
  }
607
+ function calculateRetainedSizes(snapshot) {
608
+ const finder = new core_2.TraceFinder();
609
+ // dominator and retained size
610
+ finder.calculateAllNodesRetainedSizes(snapshot);
611
+ }
612
+ function isCollectObject(node) {
613
+ if (node.type !== 'object') {
614
+ return false;
615
+ }
616
+ return (node.name === 'Map' ||
617
+ node.name === 'Set' ||
618
+ node.name === 'WeakMap' ||
619
+ node.name === 'WeakSet');
620
+ }
621
+ function getCollectionFanout(node) {
622
+ if (node.type !== 'object') {
623
+ return 0;
624
+ }
625
+ if (node.name === 'Array') {
626
+ return node.edge_count;
627
+ }
628
+ else if (node.name === 'Map' ||
629
+ node.name === 'Set' ||
630
+ node.name === 'WeakMap' ||
631
+ node.name === 'WeakSet') {
632
+ const table = node.getReferenceNode('table');
633
+ if (table) {
634
+ return table.edge_count;
635
+ }
636
+ }
637
+ return 0;
638
+ }
607
639
  exports.default = {
608
640
  aggregateDominatorMetrics,
641
+ calculateRetainedSizes,
609
642
  defaultAnalysisArgs,
610
643
  filterOutLargestObjects,
644
+ getCollectionFanout,
611
645
  getDominatorNodes,
612
646
  getObjectOutgoingEdgeCount,
613
647
  getSnapshotDirForAnalysis,
614
648
  getSnapshotFileForAnalysis,
649
+ isCollectObject,
615
650
  isNodeWorthInspecting,
616
651
  loadHeapSnapshot,
617
652
  getHeapFromFile,
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=HeapAnalysis.test.d.ts.map
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  /** @internal */
11
11
  export declare function registerPackage(): Promise<void>;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
11
  import type { MemLabConfig } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
11
  import { BaseOption, MemLabConfig } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
11
  import { BaseOption, MemLabConfig } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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,26 @@
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 web_perf_infra
9
+ */
10
+ import type { HeapAnalysisOptions } from '../PluginUtils';
11
+ import type { BaseOption } from '@memlab/core';
12
+ import BaseAnalysis from '../BaseAnalysis';
13
+ declare class CollectionUnboundGrowthAnalysis extends BaseAnalysis {
14
+ getCommandName(): string;
15
+ /** @internal */
16
+ getDescription(): string;
17
+ /** @internal */
18
+ getOptions(): BaseOption[];
19
+ /** @internal */
20
+ analyzeSnapshotFromFile(file: string): Promise<void>;
21
+ /** @internal */
22
+ process(options: HeapAnalysisOptions): Promise<void>;
23
+ private checkUnboundCollection;
24
+ }
25
+ export default CollectionUnboundGrowthAnalysis;
26
+ //# sourceMappingURL=CollectionUnboundGrowthAnalysis.d.ts.map
@@ -0,0 +1,169 @@
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 web_perf_infra
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 fs_1 = __importDefault(require("fs"));
25
+ const core_1 = require("@memlab/core");
26
+ const BaseAnalysis_1 = __importDefault(require("../BaseAnalysis"));
27
+ const HeapAnalysisSnapshotDirectoryOption_1 = __importDefault(require("../options/HeapAnalysisSnapshotDirectoryOption"));
28
+ const PluginUtils_1 = __importDefault(require("../PluginUtils"));
29
+ const __1 = require("..");
30
+ class CollectionUnboundGrowthAnalysis extends BaseAnalysis_1.default {
31
+ getCommandName() {
32
+ return 'unbound-collection';
33
+ }
34
+ /** @internal */
35
+ getDescription() {
36
+ return ('Check unbound collection growth ' +
37
+ '(e.g., Map with growing number of entries)');
38
+ }
39
+ /** @internal */
40
+ getOptions() {
41
+ return [new HeapAnalysisSnapshotDirectoryOption_1.default()];
42
+ }
43
+ /** @internal */
44
+ analyzeSnapshotFromFile(file) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
+ const f = file;
48
+ throw core_1.utils.haltOrThrow(`${this.constructor.name} does not support analyzeSnapshotFromFile`);
49
+ });
50
+ }
51
+ /** @internal */
52
+ process(options) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const snapshotDir = PluginUtils_1.default.getSnapshotDirForAnalysis(options);
55
+ const opt = snapshotDir ? { minSnapshots: 2, snapshotDir } : {};
56
+ core_1.config.chaseWeakMapEdge = false;
57
+ core_1.analysis.visualizeMemoryUsage(opt);
58
+ core_1.utils.checkSnapshots(opt);
59
+ yield this.checkUnboundCollection(opt);
60
+ });
61
+ }
62
+ checkUnboundCollection(options) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const nodeInfo = Object.create(null);
65
+ let hasCheckedFirstSnapshot = false;
66
+ let snapshot = null;
67
+ const initNodeInfo = (node) => {
68
+ if (!__1.PluginUtils.isCollectObject(node)) {
69
+ return;
70
+ }
71
+ const n = __1.PluginUtils.getCollectionFanout(node);
72
+ nodeInfo[node.id] = {
73
+ type: node.type,
74
+ name: node.name,
75
+ min: n,
76
+ max: n,
77
+ history: [n],
78
+ node,
79
+ };
80
+ };
81
+ const updateNodeInfo = (node) => {
82
+ const item = nodeInfo[node.id];
83
+ if (!item) {
84
+ return;
85
+ }
86
+ if (node.name !== item.name || node.type !== item.type) {
87
+ nodeInfo[node.id] = null;
88
+ return;
89
+ }
90
+ const n = __1.PluginUtils.getCollectionFanout(node);
91
+ // only monotonic increase?
92
+ if (core_1.config.monotonicUnboundGrowthOnly && n < item.max) {
93
+ nodeInfo[node.id] = null;
94
+ return;
95
+ }
96
+ item.history.push(n);
97
+ item.max = Math.max(item.max, n);
98
+ item.min = Math.min(item.min, n);
99
+ };
100
+ core_1.info.overwrite('Checking unbounded collections...');
101
+ const snapshotFiles = options.snapshotDir
102
+ ? // load snapshots from a directory
103
+ core_1.utils.getSnapshotFilesInDir(options.snapshotDir)
104
+ : // load snapshots based on the visit sequence meta data
105
+ core_1.utils.getSnapshotFilesFromTabsOrder();
106
+ for (const file of snapshotFiles) {
107
+ // force GC before loading each snapshot
108
+ if (global.gc) {
109
+ global.gc();
110
+ }
111
+ // load and preprocess heap snapshot
112
+ const opt = { buildNodeIdIndex: true, verbose: true };
113
+ snapshot = yield core_1.utils.getSnapshotFromFile(file, opt);
114
+ __1.PluginUtils.calculateRetainedSizes(snapshot);
115
+ // keep track of heap objects
116
+ if (!hasCheckedFirstSnapshot) {
117
+ // record Ids in the snapshot
118
+ snapshot.nodes.forEach(initNodeInfo);
119
+ hasCheckedFirstSnapshot = true;
120
+ }
121
+ else {
122
+ snapshot.nodes.forEach(updateNodeInfo);
123
+ }
124
+ }
125
+ // exit if no heap snapshot found
126
+ if (!hasCheckedFirstSnapshot) {
127
+ return;
128
+ }
129
+ // post process and print the unbounded objects
130
+ const idsInLastSnapshot = new Set();
131
+ snapshot === null || snapshot === void 0 ? void 0 : snapshot.nodes.forEach(node => {
132
+ idsInLastSnapshot.add(node.id);
133
+ });
134
+ let ids = [];
135
+ for (const key in nodeInfo) {
136
+ const id = parseInt(key, 10);
137
+ const item = nodeInfo[id];
138
+ if (!item) {
139
+ continue;
140
+ }
141
+ if (!idsInLastSnapshot.has(id)) {
142
+ continue;
143
+ }
144
+ if (item.min === item.max) {
145
+ continue;
146
+ }
147
+ ids.push(Object.assign({ id }, item));
148
+ }
149
+ if (ids.length === 0) {
150
+ core_1.info.midLevel('No increasing collections found.');
151
+ return;
152
+ }
153
+ ids = ids
154
+ .sort((o1, o2) => o2.history[o2.history.length - 1] - o1.history[o1.history.length - 1])
155
+ .slice(0, 20);
156
+ const formatter = (n) => `${n}`;
157
+ ids.forEach(item => (item.historyNumberFormatter = formatter));
158
+ // print on terminal
159
+ const str = core_1.serializer.summarizeUnboundedObjects(ids, { color: true });
160
+ core_1.info.topLevel('Top growing objects in sizes:');
161
+ core_1.info.lowLevel(' (Use `memlab trace --node-id=@ID` to get trace)');
162
+ core_1.info.topLevel('\n' + str);
163
+ // save results to file
164
+ const csv = core_1.serializer.summarizeUnboundedObjectsToCSV(ids);
165
+ fs_1.default.writeFileSync(core_1.config.unboundObjectCSV, csv, 'UTF-8');
166
+ });
167
+ }
168
+ }
169
+ exports.default = CollectionUnboundGrowthAnalysis;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import type { IHeapNode } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  declare const _default: Set<string>;
12
12
  export default _default;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @format
9
9
  * @lightSyntaxTransform
10
- * @oncall ws_labs
10
+ * @oncall web_perf_infra
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.default = new Set([
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -31,7 +31,8 @@ class ObjectUnboundGrowthAnalysis extends BaseAnalysis_1.default {
31
31
  }
32
32
  /** @internal */
33
33
  getDescription() {
34
- return 'Check unbound object growth';
34
+ return ('Check unbound object growth ' +
35
+ '(a single object with growing retained size)');
35
36
  }
36
37
  /** @internal */
37
38
  getOptions() {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -37,7 +37,8 @@ class ShapeUnboundGrowthAnalysis extends BaseAnalysis_1.default {
37
37
  }
38
38
  /** @internal */
39
39
  getDescription() {
40
- return 'Get shapes with unbound growth';
40
+ return ('Get shapes with unbound growth ' +
41
+ '(a class of objects with growing aggregated retained size)');
41
42
  }
42
43
  /** @internal */
43
44
  getOptions() {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HeapAnalysisOptions } from '../PluginUtils';
11
11
  import { BaseOption } from '@memlab/core';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/heap-analysis",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "license": "MIT",
5
5
  "description": "heap analysis plugins for memlab",
6
6
  "author": "Liang Gong <lgong@fb.com>",
@@ -16,7 +16,8 @@
16
16
  "main": "dist/index.js",
17
17
  "types": "dist/index.d.ts",
18
18
  "files": [
19
- "dist"
19
+ "dist",
20
+ "LICENSE"
20
21
  ],
21
22
  "dependencies": {
22
23
  "@memlab/core": "^1.1.10",
@@ -43,7 +44,7 @@
43
44
  },
44
45
  "repository": {
45
46
  "type": "git",
46
- "url": "git+https://github.com/facebookincubator/memlab.git",
47
+ "url": "git+https://github.com/facebook/memlab.git",
47
48
  "directory": "packages/heap-analysis"
48
49
  },
49
50
  "scripts": {
@@ -53,7 +54,7 @@
53
54
  "clean-pkg": "rm -rf ./dist && rm -rf ./node_modules && rm -f ./tsconfig.tsbuildinfo"
54
55
  },
55
56
  "bugs": {
56
- "url": "https://github.com/facebookincubator/memlab/issues"
57
+ "url": "https://github.com/facebook/memlab/issues"
57
58
  },
58
- "homepage": "https://github.com/facebookincubator/memlab#readme"
59
+ "homepage": "https://github.com/facebook/memlab#readme"
59
60
  }