memlab 1.1.8-alpha → 1.1.11-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 +24 -4
- package/bin/{memlab-js → memlab} +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -12,22 +12,26 @@ 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
|
-
//
|
|
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
|
}
|
|
23
25
|
|
|
24
26
|
// action where we want to detect memory leaks: click the Hotels button
|
|
25
27
|
async function action(page) {
|
|
28
|
+
// puppeteer page API
|
|
26
29
|
await page.click('button[aria-label="Hotels"]');
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
// action where we want to go back to the step before: click clear search
|
|
30
33
|
async function back(page) {
|
|
34
|
+
// puppeteer page API
|
|
31
35
|
await page.click('[aria-label="Clear search"]');
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -35,12 +39,28 @@ module.exports = {action, back, url};
|
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
Now run memlab with the scenario file, memlab will interact with
|
|
38
|
-
the web page and
|
|
42
|
+
the web page and detect memory leaks with built-in leak detectors:
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
45
|
memlab run --scenario test-google-maps.js
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
If you want to use a self-defined leak detector, add a `filterLeak` callback
|
|
49
|
+
in the scenario file. `filterLeak` will be called for every unreleased heap
|
|
50
|
+
object (`node`) allocated by the target interaction.
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
function filterLeak(node, heap) {
|
|
54
|
+
// ... your leak detector logic
|
|
55
|
+
// return true to mark the node as a memory leak
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`heap` is the graph representation of the final JavaScript heap snapshot.
|
|
60
|
+
For more details, view the [doc site](https://facebookincubator.github.io/memlab).
|
|
61
|
+
|
|
62
|
+
### Heap Analysis and Investigation
|
|
63
|
+
|
|
44
64
|
View which object keeps growing in size during interaction in the previous run:
|
|
45
65
|
```bash
|
|
46
66
|
memlab analyze unbound-object
|
|
@@ -52,7 +72,7 @@ Analyze pre-fetched v8/hermes `.heapsnapshot` files:
|
|
|
52
72
|
memlab analyze unbound-object --snapshot-dir <DIR_OF_SNAPSHOT_FILES>
|
|
53
73
|
```
|
|
54
74
|
|
|
55
|
-
Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](/
|
|
75
|
+
Use `memlab analyze` to view all built-in memory analyses. For extension, view the [doc site](https://facebookincubator.github.io/memlab).
|
|
56
76
|
|
|
57
77
|
View retainer trace of a particular object:
|
|
58
78
|
```bash
|
|
@@ -63,7 +83,7 @@ Use `memlab help` to view all CLI commands.
|
|
|
63
83
|
|
|
64
84
|
## APIs
|
|
65
85
|
|
|
66
|
-
Use the `memlab` package to start a E2E run in browser and detect memory leaks
|
|
86
|
+
Use the `memlab` npm package to start a E2E run in browser and detect memory leaks.
|
|
67
87
|
|
|
68
88
|
```javascript
|
|
69
89
|
const memlab = require('memlab');
|
package/bin/{memlab-js → memlab}
RENAMED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memlab",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11-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
|
|
11
|
+
"memlab": "bin/memlab"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"typescript": "^4.6.3"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
|
+
"preinstall": "./bin/preinstall",
|
|
53
54
|
"build-pkg": "tsc",
|
|
54
55
|
"clean-pkg": "rm -rf ./dist && rm -rf ./node_modules && rm -f ./tsconfig.tsbuildinfo"
|
|
55
56
|
},
|