Shubhra Kar @shubhrakar April, 2014 Memory Leak Analysis
May 06, 2015
Shubhra Kar@shubhrakar
April, 2014
Memory Leak Analysis
heapdump for V8 snapshots by @bnoordhuis
npm install heapdumpAdd 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’)
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>
4
Heapdump analysis in Chrome Dev Tools
5
Heapdump analysis in Chrome Dev Tools
StrongOps - Memory Profiling and Leak Detection
A nasty one ! (memory leak)
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/