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
- Use gc-stats to calculate when to make a OoM heapdumo instead of process.memoryUsage() as this memory information (heapTotal) is growing over time, which is not what was expected while developing.
- Stringify gc-stats output, so it runs over only 1 line.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
11-17-2017 - Paul Rütter
2
+
- 1.0.10 - Use gc-stats to calculate when to make a OoM heapdumo instead of process.memoryUsage() as this memory information (heapTotal) is growing over time, which is not expected.
3
+
- Stringify gc-stats output, so it runs over only 1 line.
4
+
1
5
06-10-2017 - Paul Rütter
2
6
- 1.0.9 - Handle exit codes better and reject promise if so.
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ It can also create heapdumps and CPU profiles on request like 'v8-profiler', but
6
6
Tested on Node.js 8.x, but should also work fine using Node.js 6.3 upwards (According to: https://chromedevtools.github.io/devtools-protocol/v8/).
7
7
8
8
# Why?
9
-
When running nodejs processes in a low memory environment, every out of memory that occurs is interesting.
9
+
When running nodejs processes in a low memory environment, every out of memory that occurs is interesting.
10
10
To figure out why a process went out of memory, a heap snapshot (e.g. heapdump) can help a lot.
11
11
This module creates a heap snapshot right before a suspected out of memory error occurs.
12
12
It shows what the heap was filled with right before the out of memory error occured.
13
13
14
14
There are several modules around which can create heapdumps (v8-profiler, node-heapdump), but these run in the same process as the one going out of memory. Often, creating heapdump won't work when the node process is already struggling.
15
-
This module creates the heap snapshot from a separate process, which solves this issue.
15
+
This module creates the heap snapshot from a separate process, which solves this issue.
16
16
17
17
# What?
18
18
It uses 'gc-stats' to determine when an out of memory error is about to occur and then fires up a new process which uses 'chrome-remote-interface' to connect with the DevTools protocol (https://chromedevtools.github.io/devtools-protocol/v8/) of the calling process. That process uses HeapProfiler to actually create the heapdump and then exits.
@@ -31,7 +31,7 @@ Just add the following snippet to your node process.
31
31
```javascript
32
32
let path =require('path');
33
33
require('node-oom-heapdump')({
34
-
threshold:90,
34
+
threshold:70,
35
35
path:path.resolve(__dirname, 'my_heapdump')
36
36
});
37
37
```
@@ -48,7 +48,7 @@ These might impact performance though.
48
48
49
49
# Options
50
50
* heapdumpOnOOM - boolean whether to create a heapdump when an out of memory occurs. Default true.
51
-
* 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 90.
51
+
* 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.
52
52
* path - the path where the heapdump ends up when an out of memory error occurs. '.heapsnapshot' is automatically appended. Defaults to this modules' directory.
53
53
* addTimestamp - add a timestamp to the out of memory heapdump filename, to make it unique. Default is false.
54
54
* limit - optionally, specify a limit to how many heapdumps will be created when being above the threshold. Default is 3.
@@ -71,7 +71,7 @@ let nodeOomHeapdump = require("node-oom-heapdump")({
// this is a full GC and the used heap size is using more than x% of the assigned heap space limit
29
-
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),stats);
28
+
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));
30
29
31
30
this.createHeapSnapshot(this._opts.path,"OoM");
32
31
@@ -158,7 +157,7 @@ class NodeOomHeapDumpImpl {
158
157
159
158
/**
160
159
* Deletes a particular snapshot from disk
161
-
* @param {String} snapshotPath - path of the heap snapshot to delete
160
+
* @param {String} snapshotPath - path of the heap snapshot to delete
162
161
* @return {Promise}
163
162
*/
164
163
deleteHeapSnapshot(snapshotPath){
@@ -178,7 +177,7 @@ class NodeOomHeapDumpImpl {
178
177
179
178
/**
180
179
* Deletes a particular CPU profile from disk
181
-
* @param {String} cpuProfilePath - path of the CPU profile to delete
180
+
* @param {String} cpuProfilePath - path of the CPU profile to delete
182
181
* @return {Promise}
183
182
*/
184
183
deleteCpuProfile(cpuProfilePath){
@@ -187,7 +186,7 @@ class NodeOomHeapDumpImpl {
187
186
188
187
/**
189
188
* Deletes a given CPU profile or heapsnapshot from disk
190
-
* @param {String} path - path to the file to delete
189
+
* @param {String} path - path to the file to delete
0 commit comments