Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function firstHeap() {
/* eslint no-console:0 */
console.log('writing first heap');
heapdump.writeSnapshot(HEAP_FILE_ONE);
}
process.once('uncaughtException', async (err) => {
HeapDump.writeSnapshot(Path.join(settings.heapdumpFolder, 'heapdump-' + Date.now() + '.heapsnapshot'));
// Don't try to catch any errors since the process is exiting anyway.
await Utils.log(err, {
logPath: settings.logPath,
writeStreamOptions: settings.writeStreamOptions
});
process.exit(1);
});
Exception.writable('disk', function disk() {
var location = path.resolve(this.directory, 'exceptions', this.filename);
//
// First write our own dump of gathered information.
//
try { fs.writeFileSync(location +'.json', JSON.stringify(this, null, 2)); }
catch (e) { console.error('Failed to write exception to disk', e); }
//
// Now try to write out the heap dump.
//
heapdump.writeSnapshot(location +'.heapsnapshot');
return this;
});
'use strict';
var fs = require('fs');
var heapdump = require('heapdump');
var name = './heapdump.heapsnapshot';
heapdump.writeSnapshot(name, function (error1, filename) {
if (error1) throw error1;
fs.unlink(filename, function (error2) {
if (error2) throw error2;
console.log('ok');
});
});
async function cleanup(innerSession, err) {
if (err) {
console.error(err);
}
await innerSession.close();
if (enableHeap) {
heapdump.writeSnapshot(`./${stamp}-iteration-${iterationNumber}.heapsnapshot`);
}
}
memwatch.on('leak', function(info) {
var file = require('path').resolve('./heapdump/' + process.pid + '-' + Date.now() + '.heapsnapshot');
heapdump.writeSnapshot(file, function(err) {
if (err) console.error(err);
else console.error('Wrote snapshot: ' + file);
});
});
}
setInterval(function() {
var f = '/tmp/bipio_NC_' + Date.now() + '.heapsnapshot';
console.log('Writing ' + f);
console.log(require.cache);
heapdump.writeSnapshot(f);
}, 60000);
}
socket.on('heapdump', data => {
console.log('heapdump');
heapdump.writeSnapshot('./logs/' + Date.now() + '.heapsnapshot');
});
}
var afterPut = put.then(function() {
//console.log("After put, heapUsed: "+process.memoryUsage().heapUsed);
heapdump.writeSnapshot('/tmp/' + Date.now() + '.heapsnapshot');
});
setTimeout(() => {
heapdump.writeSnapshot(Date.now()+".heapsnapshot");
console.log("snapshot written.");
}, 400000);
});