You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-7
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Node module which will create a V8 heap snapshot right before an "Out of Memory"
5
5
6
6
It can also create heapdumps and CPU profiles on request like 'v8-profiler', but does this off-process so it doesn't interfere with execution of the main process.
Tested on Node.js 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x and 16.x.
9
9
No support for Node.js < 7.0 at the moment (although this can be fixed if needed).
10
10
11
11
Also comes with prebuilt binaries (hosted on Github releases), thanks to Stuart Miller (https://github.com/spmiller).
@@ -63,17 +63,12 @@ On Node.js 12.x the latter two flags seem to cause some stability issues (see ht
63
63
64
64
# Options
65
65
* heapdumpOnOOM - boolean whether to create a heapdump when an out of memory occurs. Default true.
66
-
* OOMImplementation - Either "NATIVE_HOOK" or "GC_MONITORING".
66
+
* OOMImplementation - Only "NATIVE_HOOK" is supported starting from 3.0.0
67
67
"NATIVE_HOOK" relies on the native v8 hook and makes sure that the heapdump is actually created when the OoM occurs. It's more impacted by the OoMKiller of Unix systems though, when being run in memory restricted environments like Docker.
68
-
"GC_MONITORING" is the old implementation, which relies on GC monitoring. It's less impacted by OoMKiller, because the 'threshold' parameter determines when to create the heapdump. Use this option when you run into the OoMKiller of the Unix OS. Default is "NATIVE_HOOK".
69
68
* path - the path where the heapdump ends up when an out of memory error occurs. '.heapsnapshot' is automatically appended. Defaults to this modules' directory.
70
69
* addTimestamp - add a timestamp to the out of memory heapdump filename, to make it unique. Default is false.
71
70
* port - optionally, the alternative DevTools protocol port. Defaults to 9229. Should map on the port given to the --inspect arg.
72
71
73
-
The following options are only relevant when OOMImplementation="GC_MONITORING".
74
-
* limit - optionally, specify a limit to how many heapdumps will be created when being above the threshold. Default is 3.
75
-
* threshold - integer between 0 and 100 (%) which determines when to make the heapdump. When the used heapSize exceeds the threshold, a heapdump is made. This value can be tuned depending on your configuration; if memory usage is very volatile, a lower value might make more sense. Default is 70.
76
-
77
72
# API
78
73
Besides creating heapdumps when an out of memory error occurs, there also is an API for creating heapdumps and CPU profiles on request. See below for the currently available API.
// this is a full GC and the used heap size is using more than x% of the assigned heap space limit
32
-
console.warn('OoM is imminent: Full GC (Mark/Sweep/Compact) complete and still more than %s% (%s%) of the heap is used. Creating heapdump now. GC stats: ',this._opts.threshold,Math.round(memoryUsagePercentage),JSON.stringify(stats));
33
-
34
-
this.createHeapSnapshot(this._opts.path,"OoM");
35
-
36
-
// block execution of other code for a while (5 second) to enable snapshot to be created
37
-
consttime=Date.now();
38
-
letdiff=0;
39
-
do{
40
-
diff=Date.now()-time;
41
-
}
42
-
while(diff<5000);
43
-
}elseif(!this._limitReached){
44
-
this._limitReached=true;
45
-
console.warn("OoM heapdump limit reached (%s); no more heapdumps will be created.",this._opts.limit);
46
-
return;
47
-
}
48
-
}
49
-
}
50
-
});
51
-
}
52
-
53
19
54
20
/**
55
21
* Calls the designated worker and returns a promise
0 commit comments