Comparing version 0.3.11 to 0.3.12
18
index.js
@@ -22,3 +22,2 @@ // Copyright (c) 2014, Ben Noordhuis <info@bnoordhuis.nl> | ||
var kForkFlag = addon.kForkFlag; | ||
var kSignalFlag = addon.kSignalFlag; | ||
@@ -31,5 +30,3 @@ | ||
if (option === '') continue; | ||
else if (option === 'fork') flags |= kForkFlag; | ||
else if (option === 'signal') flags |= kSignalFlag; | ||
else if (option === 'nofork') flags &= ~kForkFlag; | ||
else if (option === 'nosignal') flags &= ~kSignalFlag; | ||
@@ -40,4 +37,15 @@ else console.error('node-heapdump: unrecognized option:', option); | ||
exports.writeSnapshot = function() { | ||
return addon.writeSnapshot.apply(null, arguments); | ||
exports.writeSnapshot = function(filename, cb) { | ||
if (typeof filename === 'function') cb = filename, filename = undefined; | ||
filename = addon.writeSnapshot(filename); | ||
var success = !!filename; | ||
// Make the callback. Yes, this is synchronous; it wasn't back when heapdump | ||
// forked before writing the snapshot, but it is now. index.js can postpone | ||
// the callback with process.nextTick() or setImmediate() if synchronicity | ||
// becomes an issue. Or just remove it, it's pretty pointless now. | ||
if (cb) { | ||
if (success) cb(null, filename); | ||
else cb(new Error('heapdump write error')); | ||
} | ||
return success; | ||
}; |
{ | ||
"name": "heapdump", | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"description": "Make a dump of the V8 heap for later inspection.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bnoordhuis/node-heapdump", |
@@ -40,10 +40,2 @@ node-heapdump | ||
Previously, node-heapdump first forked the process before writing the snapshot, | ||
making it effectively asynchronous. However, it broke the comparison view in | ||
Chrome DevTools and is fundamentally incompatible with node.js v0.12. If you | ||
really want the old behavior and know what you are doing, you can enable it | ||
again by setting `NODE_HEAPDUMP_OPTIONS=fork` in the environment: | ||
$ env NODE_HEAPDUMP_OPTIONS=fork node script.js | ||
On UNIX platforms, you can force a snapshot by sending the node.js process | ||
@@ -68,3 +60,4 @@ a SIGUSR2 signal: | ||
Select the dump file and click `Open`. You can now inspect the heap snapshot | ||
at your leisure. | ||
at your leisure. Some snapshots may take a long time to load, on the order of | ||
minutes or even hours. | ||
@@ -71,0 +64,0 @@ Note that Chrome will refuse to load the file unless it has the `.heapsnapshot` |
@@ -32,3 +32,3 @@ // Copyright (c) 2014, Krishna Raman <kraman@gmail.com> | ||
var heapSnapshotFile = 'heapdump-' + Date.now() + '.heapsnapshot'; | ||
var heapSnapshotFile = 'heapdump-*.heapsnapshot'; | ||
shelljs.rm('-f', heapSnapshotFile); | ||
@@ -45,3 +45,3 @@ | ||
heapdump.writeSnapshot(heapSnapshotFile, waitForHeapdump); | ||
heapdump.writeSnapshot(waitForHeapdump); | ||
}); | ||
@@ -48,0 +48,0 @@ server.listen(0); |
@@ -32,3 +32,3 @@ // Copyright (c) 2014, Krishna Raman <kraman@gmail.com> | ||
var heapSnapshotFile = 'heapdump-*.heapsnapshot'; | ||
var heapSnapshotFile = 'heapdump-' + Date.now() + '.heapsnapshot'; | ||
shelljs.rm('-f', heapSnapshotFile); | ||
@@ -45,3 +45,3 @@ | ||
heapdump.writeSnapshot(waitForHeapdump); | ||
heapdump.writeSnapshot(heapSnapshotFile, waitForHeapdump); | ||
}); | ||
@@ -48,0 +48,0 @@ server.listen(0); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13
194
22554
73