Exposes statistics about V8 garbage collections (GCs) after they have been executed.
npm install --save gcstats.js
Require the module and subscribe to the stats
event:
var gcStats = require('gcstats.js');
gcStats.on('stats', function(stats) {
console.log(stats);
});
This will print blobs like this whenever a GC happens:
{
"start": 271925068593439,
"end": 271925070343402,
"gctype": 1,
"before": {
"totalHeapSize": 10481664,
"totalHeapExecutableSize": 5242880,
"usedHeapSize": 5761048,
"heapSizeLimit": 1535115264,
"totalPhysicalSize": 10481664
},
"after": {
"totalHeapSize": 11530240,
"totalHeapExecutableSize": 5242880,
"usedHeapSize": 5512464,
"heapSizeLimit": 1535115264,
"totalPhysicalSize": 11530240
}
}
start
: Start time of the GC measured using uv_hrtime (nanoseconds).end
: End time of the GC measured using uv_hrtime (nanoseconds).totalHeapSize
: Number of bytes V8 has allocated for the heap. This can grow if usedHeap needs more.usedHeapSize
: Number of bytes in use by application datatotalHeapExecutableSize
: Number of bytes for compiled bytecode and JITed codeheapSizeLimit
: The absolute limit the heap cannot exceedtotalPhysicalSize
: Commited size (node 0.11+)gctype
: What kind of GC was executed. Refer to the v8 docs of the GCType
enum for a list of possible values.GC stats depend on C++ extensions which are compiled when the gcstats.js
module is installed. Compatibility information can be inspected via the Travis-CI build jobs.
node-gcstats
was written by @dainis and later adapted by @bripkens and renamed to gcstats.js
.