@memlab/api 1.0.6 → 1.0.7

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.
@@ -30,7 +30,7 @@ class TestObject {
30
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
31
  const obj = new TestObject();
32
32
  // get a heap snapshot of the current program state
33
- const heap = yield (0, core_1.getNodeInnocentHeap)();
33
+ const heap = yield (0, core_1.takeNodeMinimalHeap)();
34
34
  const node = heap.getAnyObjectWithClassName('TestObject');
35
35
  console.log(node === null || node === void 0 ? void 0 : node.name);
36
36
  });
@@ -23,7 +23,7 @@ const heap_analysis_1 = require("@memlab/heap-analysis");
23
23
  (function () {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
- const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
26
+ const heap = yield (0, heap_analysis_1.getFullHeapFromFile)(heapFile);
27
27
  // get the total number of heap objects
28
28
  heap.nodes.length;
29
29
  heap.nodes.forEach((node) => {
@@ -23,7 +23,7 @@ const heap_analysis_1 = require("@memlab/heap-analysis");
23
23
  (function () {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
- const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
26
+ const heap = yield (0, heap_analysis_1.getFullHeapFromFile)(heapFile);
27
27
  // get the total number of heap references
28
28
  heap.edges.length;
29
29
  heap.edges.forEach((edge) => {
@@ -23,7 +23,7 @@ const heap_analysis_1 = require("@memlab/heap-analysis");
23
23
  (function () {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
- const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
26
+ const heap = yield (0, heap_analysis_1.getFullHeapFromFile)(heapFile);
27
27
  const node = heap.getNodeById(1);
28
28
  if (node) {
29
29
  console.log(node.id);
@@ -29,13 +29,13 @@ test('memory test', () => __awaiter(void 0, void 0, void 0, function* () {
29
29
  core_1.config.muteConsole = true;
30
30
  let obj = new TestObject();
31
31
  // get a heap snapshot of the current program state
32
- let heap = yield (0, core_1.getNodeInnocentHeap)();
32
+ let heap = yield (0, core_1.takeNodeMinimalHeap)();
33
33
  // call some function that may add references to obj
34
34
  // rabbitHole()
35
35
  expect(heap.hasObjectWithClassName('TestObject')).toBe(true);
36
36
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
37
  obj = null;
38
- heap = yield (0, core_1.getNodeInnocentHeap)();
38
+ heap = yield (0, core_1.takeNodeMinimalHeap)();
39
39
  // if rabbitHole does not add new references, the obj can be GCed
40
40
  expect(heap.hasObjectWithClassName('TestObject')).toBe(false);
41
41
  }), 30000);
@@ -25,7 +25,7 @@ const heap_analysis_1 = require("@memlab/heap-analysis");
25
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
26
  const object = { 'memlab-test-heap-property': 'memlab-test-heap-value' };
27
27
  const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
28
- const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
28
+ const heap = yield (0, heap_analysis_1.getFullHeapFromFile)(heapFile);
29
29
  // should be true
30
30
  console.log(heap.hasObjectWithPropertyName('memlab-test-heap-property'));
31
31
  });
@@ -28,7 +28,7 @@ test('memory test', () => __awaiter(void 0, void 0, void 0, function* () {
28
28
  // tag o2 with marker: "memlab-mark-2"
29
29
  (0, core_1.tagObject)(o2, 'memlab-mark-2');
30
30
  o2 = null;
31
- const heap = yield (0, core_1.getNodeInnocentHeap)();
31
+ const heap = yield (0, core_1.takeNodeMinimalHeap)();
32
32
  // expect object with marker "memlab-mark-1" exists
33
33
  expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
34
34
  // expect object with marker "memlab-mark-2" can be GCed
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare function registerPackage(): Promise<void>;
12
12
  export * from './API';
13
13
  export * from '@memlab/heap-analysis';
14
14
  export { default as BrowserInteractionResultReader } from './result-reader/BrowserInteractionResultReader';
15
- export { dumpNodeHeapSnapshot, getNodeInnocentHeap } from '@memlab/core';
15
+ export { dumpNodeHeapSnapshot, getNodeInnocentHeap, takeNodeMinimalHeap, } from '@memlab/core';
16
16
  /** @internal */
17
17
  export { config } from '@memlab/core';
18
18
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.config = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.BrowserInteractionResultReader = exports.registerPackage = void 0;
38
+ exports.config = exports.takeNodeMinimalHeap = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.BrowserInteractionResultReader = exports.registerPackage = void 0;
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const core_1 = require("@memlab/core");
41
41
  /** @internal */
@@ -52,6 +52,7 @@ Object.defineProperty(exports, "BrowserInteractionResultReader", { enumerable: t
52
52
  var core_2 = require("@memlab/core");
53
53
  Object.defineProperty(exports, "dumpNodeHeapSnapshot", { enumerable: true, get: function () { return core_2.dumpNodeHeapSnapshot; } });
54
54
  Object.defineProperty(exports, "getNodeInnocentHeap", { enumerable: true, get: function () { return core_2.getNodeInnocentHeap; } });
55
+ Object.defineProperty(exports, "takeNodeMinimalHeap", { enumerable: true, get: function () { return core_2.takeNodeMinimalHeap; } });
55
56
  /** @internal */
56
57
  var core_3 = require("@memlab/core");
57
58
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return core_3.config; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/api",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "license": "MIT",
5
5
  "description": "memlab API",
6
6
  "author": "Liang Gong <lgong@fb.com>",