memlab 1.1.7-alpha → 1.1.10-alpha

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/README.md CHANGED
@@ -12,11 +12,13 @@ Install the CLI
12
12
  npm install -g memlab
13
13
  ```
14
14
 
15
+ ### Find Memory Leaks
16
+
15
17
  To find memory leaks in Google Maps, you can create a scenario file defining how
16
18
  to interact with the Google Maps, let's name it `test-google-maps.js`:
17
19
 
18
20
  ```javascript
19
- // Visit Google Maps
21
+ // initial page load url: Google Maps
20
22
  function url() {
21
23
  return 'https://www.google.com/maps/@37.386427,-122.0428214,11z';
22
24
  }
@@ -35,12 +37,28 @@ module.exports = {action, back, url};
35
37
  ```
36
38
 
37
39
  Now run memlab with the scenario file, memlab will interact with
38
- the web page and show detected memory leaks:
40
+ the web page and detect memory leaks with built-in leak detectors:
39
41
 
40
42
  ```bash
41
43
  memlab run --scenario test-google-maps.js
42
44
  ```
43
45
 
46
+ If you want to use a self-defined leak detector, add a `filterLeak` callback
47
+ in the scenario file. `filterLeak` will be called for every unreleased heap
48
+ object (`node`) allocated by the target interaction.
49
+
50
+ ```javascript
51
+ function filterLeak(node, heap) {
52
+ // ... your leak detector logic
53
+ // return true to mark the node as a memory leak
54
+ };
55
+ ```
56
+
57
+ `heap` is the graph representation of the final JavaScript heap snapshot.
58
+ For more details, view the [doc site](https://facebookincubator.github.io/memlab).
59
+
60
+ ### Heap Analysis and Investigation
61
+
44
62
  View which object keeps growing in size during interaction in the previous run:
45
63
  ```bash
46
64
  memlab analyze unbound-object
@@ -52,7 +70,7 @@ Analyze pre-fetched v8/hermes `.heapsnapshot` files:
52
70
  memlab analyze unbound-object --snapshot-dir <DIR_OF_SNAPSHOT_FILES>
53
71
  ```
54
72
 
55
- Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](/tba).
73
+ Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](https://facebookincubator.github.io/memlab).
56
74
 
57
75
  View retainer trace of a particular object:
58
76
  ```bash
@@ -63,7 +81,7 @@ Use `memlab help` to view all CLI commands.
63
81
 
64
82
  ## APIs
65
83
 
66
- Use the `memlab` package to start a E2E run in browser and detect memory leaks:
84
+ Use the `memlab` npm package to start a E2E run in browser and detect memory leaks.
67
85
 
68
86
  ```javascript
69
87
  const memlab = require('memlab');
@@ -79,4 +97,4 @@ const scenario = {
79
97
  back: async (page) => await page.click('[aria-label="Clear search"]'),
80
98
  }
81
99
  memlab.run({scenario});
82
- ```
100
+ ```
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memlab",
3
- "version": "1.1.7-alpha",
3
+ "version": "1.1.10-alpha",
4
4
  "license": "MIT",
5
5
  "description": "memlab is a framework that analyzes memory and finds memory leaks in JavaScript applications.",
6
6
  "main": "dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "bin": {
11
- "memlab": "bin/memlab-js"
11
+ "memlab": "bin/memlab"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"