memlab 1.0.0-alpha → 1.0.4-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.
Files changed (2) hide show
  1. package/README.md +77 -5
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,11 +1,83 @@
1
- # `memlab`
1
+ # memlab
2
2
 
3
- > TODO: description
3
+ memlab is an E2E testing and analysis framework for finding memory leaks
4
+ in-browser JavaScript Code. The CLI Toolbox and library provide extensible
5
+ interfaces for analyzing heap snapshots taken from Chrome, Node.js, Hermes,
6
+ and Electron.js.
4
7
 
5
- ## Usage
8
+ ## CLI Usage
6
9
 
10
+ Install the CLI
11
+
12
+ ```bash
13
+ npm install -g @memlab
14
+ ```
15
+
16
+ To find memory leaks in Google Maps, create a scenario file defining how
17
+ we want to interact with the Google Maps, let's name it `test-google-maps.js`:
18
+
19
+ ```
20
+ // Visit Google Maps
21
+ function url() {
22
+ return 'https://www.google.com/maps/@37.386427,-122.0428214,11z';
23
+ }
24
+
25
+ // action where we want to detect memory leaks: click the Hotels button
26
+ async function action(page) {
27
+ await page.click('button[aria-label="Hotels"]');
28
+ }
29
+
30
+ // action where we want to go back to the step before: click clear search
31
+ async function back(page) {
32
+ await page.click('[aria-label="Clear search"]');
33
+ }
34
+
35
+ module.exports = {action, back, url};
36
+ ```
37
+
38
+ Now run memlab with the scenario file, memlab will interaction with
39
+ the web page and show detected memory leaks:
40
+
41
+ ```bash
42
+ memlab run --scenario test-google-maps.js
43
+ ```
44
+
45
+ View which object keeps growing in size during interaction in the previous run:
46
+ ```bash
47
+ memlab analyze unbound-object
7
48
  ```
8
- const api = require('memlab');
9
49
 
10
- // TODO: DEMONSTRATE API
50
+ Analyze pre-fetched v8/hermes `.heapsnapshot` files:
51
+
52
+ ```bash
53
+ memlab analyze unbound-object --snapshot-dir <DIR_OF_SNAPSHOT_FILES>
54
+ ```
55
+
56
+ Use `memlab analyze` to view all memory analyses. For extension, view the [doc site](/tba).
57
+
58
+ View retain trace of a particular object:
59
+ ```bash
60
+ memlab report --nodeId <HEAP_OBJECT_ID>
61
+ ```
62
+
63
+ Use `memlab help` to view all CLI commands.
64
+
65
+ ## APIs
66
+
67
+ Use the `memlab` library to start a E2E run in browser and detect memory leaks.
68
+
69
+ ```javascript
70
+ const memlab = require('memlab');
71
+
72
+ const scenario = {
73
+ // initial page load url
74
+ url: () => 'https://www.google.com/maps/@37.386427,-122.0428214,11z',
75
+
76
+ // action where we want to detect memory leaks
77
+ action: async (page) => await page.click('button[aria-label="Hotels"]'),
78
+
79
+ // action where we want to go back to the step before
80
+ back: async (page) => await page.click('[aria-label="Clear search"]'),
81
+ }
82
+ memlab.run({scenario});
11
83
  ```
package/package.json CHANGED
@@ -1,10 +1,6 @@
1
1
  {
2
2
  "name": "memlab",
3
- "version": "1.0.0-alpha",
4
- "repository": {
5
- "type": "git",
6
- "url": "git+https://github.com/facebookincubator/memlab.git"
7
- },
3
+ "version": "1.0.4-alpha",
8
4
  "license": "MIT",
9
5
  "description": "memlab is a framework that analyzes memory and finds memory leaks in JavaScript applications.",
10
6
  "main": "dist/index.js",
@@ -68,6 +64,10 @@
68
64
  "./packages/api",
69
65
  "./packages/cli"
70
66
  ],
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "git+https://github.com/facebookincubator/memlab.git"
70
+ },
71
71
  "bugs": {
72
72
  "url": "https://github.com/facebookincubator/memlab/issues"
73
73
  },