node-oom-heapdump
Advanced tools
Comparing version 1.0.4 to 1.0.5
03-10-2017 - Paul Rütter | ||
- 1.0.5 - Change heap calculation. | ||
03-10-2017 - Paul Rütter | ||
- 1.0.4 - Add error handler in case the calling process is not running anymore. Also, block execution a while to allow heapdump to be created. | ||
@@ -3,0 +6,0 @@ |
@@ -55,3 +55,3 @@ let nodeOomLib = require("./lib"); | ||
if (options.threshold === undefined) { | ||
options.threshold = 75; | ||
options.threshold = 90; | ||
} else { | ||
@@ -58,0 +58,0 @@ options.threshold = parseInt(options.threshold); |
@@ -21,8 +21,8 @@ let cp = require("child_process"); | ||
if (stats.gctype === 2 && !this._busy) { | ||
let heapSizeUsedPercentage = (parseInt(stats.after.totalHeapSize) / parseInt(stats.after.heapSizeLimit)) * 100; | ||
if (heapSizeUsedPercentage > this._opts.threshold) { | ||
let memoryUsage = process.memoryUsage(); | ||
var memoryUsagePercentage = Math.round((memoryUsage.heapUsed / memoryUsage.heapTotal) * 100); | ||
if (memoryUsagePercentage > this._opts.threshold) { | ||
// this is a full GC and the used heap size is using more than x% of the assigned heap space limit | ||
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); | ||
// this is a full GC and the used heap size is using more than 80% of the assigned heap space limit | ||
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(heapSizeUsedPercentage), stats); | ||
this.createHeapSnapshot(path.resolve('./' + this._opts.path + '.heapsnapshot'), "OoM"); | ||
@@ -29,0 +29,0 @@ |
{ | ||
"name": "node-oom-heapdump", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Create a V8 heap snapshot right before an \"Out of Memory\" error occurs, or create a heap snapshot on request.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,3 @@ # node-oom-heapdump | ||
require("node-oom-heapdump")({ | ||
threshold: 75, | ||
threshold: 90, | ||
path: "./my_heapdump" | ||
@@ -50,3 +50,3 @@ }); | ||
* heapdumpOnOOM - boolean whether to create a heapdump when an out of memory occurs. Default true. | ||
* threshold - integer between 0 and 100 (%) which determines when to make the heapdump. When the used heapSize exceeds the threshold, a heapdump is made. | ||
* 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. | ||
* path - the path where the heapdump ends up when an out of memory error occurs. | ||
@@ -53,0 +53,0 @@ * port - optionally, the alternative DevTools protocol port. Defaults to 9229. Should map on the port given to the --inspect arg. |
let oom = require("../index.js")({ | ||
threshold: 75, | ||
threshold: 90, | ||
path: "../my_heapdump", | ||
@@ -4,0 +4,0 @@ heapdumpOnOOM: true |
15313
228