require('heapdump');
var leakyData = [];
var nonLeakyData = [];
function generateHeapDumpAndStats(){
//1. Force garbage collection every time this function is called
try {
global.gc();
} catch (e) {
console.log("You must run program with 'node --expose-gc index.js' or 'npm start'");
process.exit();
}
//2. Output Heap stats
var heapUsed = process.memoryUsage().heapUsed;
//console.log("Program is using " + heapUsed + " bytes of Heap.");
debug("Program is using " + heapUsed + " bytes of Heap.");
//3. Get Heap dump
//process.kill(process.pid, 'SIGUSR2');
}
setInterval(generateHeapDumpAndStats, 2000);