Weitere ähnliche Inhalte
Mehr von Shubhra Kar (14)
Kürzlich hochgeladen (20)
Node.js memory analysis
- 2. heapdump for V8 snapshots by @bnoordhuis
npm install heapdump
Add to app : var heapdump = require(‘heapdump’)
Method 1 : writeSnapshot
Method 2 : SIGUSR2 (Unix only)
Make sure your directory is writable
var heapdump = require('heapdump')
...
heapdump.writeSnapshot()
kill –USR2 <pid>
process.chdir('/path/to/writeable/dir’)
- 3. heapdump for V8 snapshots by @bnoordhuis
Programmatic heap snapshots (timer based)
Programmatic heap snapshots (threshold based)
var heapdump = require('heapdump')
...
setInterval(function () {
heapdump.writeSnapshot()
}, 6000 * 30) <strong>(1)</strong>
var heapdump = require('heapdump')
var nextMBThreshold = 0 <strong>(1)</strong>
setInterval(function () {
var memMB = process.memoryUsage().rss / 1048576
<strong>(2)</strong>
if (memMB > nextMBThreshold) { <strong>(3)</strong>
heapdump.writeSnapshot()
nextMBThreshold += 100
}
}, 6000 * 2) <strong>(4)</strong>
- 8. Good references
Memory Analysis 101 :https://developers.google.com/chrome-
developer-tools/docs/memory-analysis-101
Taming the Unicorn: Easing JavaScript Memory profiling in Chrome
DevTools :http://addyosmani.com/blog/taming-the-unicorn-easing-
javascript-memory-profiling-in-devtools/
StrongLoop Blog : http://strongloop.com/strongblog/how-to-heap-
snapshots/
StrongOps : http://strongloop.com/node-js-performance/strongops/
8