memlab 1.1.8-alpha → 1.1.9-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
@@ -9,14 +9,16 @@ for analyzing heap snapshots taken from Chrome/Chromium, Node.js, Hermes, and El
9
9
  Install the CLI
10
10
 
11
11
  ```bash
12
- npm install -g memlab
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,27 @@ 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
+ ```
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
+
59
+ ### Heap Analysis and Investigation
60
+
44
61
  View which object keeps growing in size during interaction in the previous run:
45
62
  ```bash
46
63
  memlab analyze unbound-object
@@ -52,7 +69,7 @@ Analyze pre-fetched v8/hermes `.heapsnapshot` files:
52
69
  memlab analyze unbound-object --snapshot-dir <DIR_OF_SNAPSHOT_FILES>
53
70
  ```
54
71
 
55
- Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](/tba).
72
+ Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](https://facebookincubator.github.io/memlab).
56
73
 
57
74
  View retainer trace of a particular object:
58
75
  ```bash
@@ -63,7 +80,7 @@ Use `memlab help` to view all CLI commands.
63
80
 
64
81
  ## APIs
65
82
 
66
- Use the `memlab` package to start a E2E run in browser and detect memory leaks:
83
+ Use the `memlab` npm package to start a E2E run in browser and detect memory leaks.
67
84
 
68
85
  ```javascript
69
86
  const memlab = require('memlab');
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memlab",
3
- "version": "1.1.8-alpha",
3
+ "version": "1.1.9-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"