SlideShare ist ein Scribd-Unternehmen logo
1 von 8
Shubhra Kar
@shubhrakar
April, 2014
Memory Leak Analysis
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’)
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 &gt; nextMBThreshold) { <strong>(3)</strong>
heapdump.writeSnapshot()
nextMBThreshold += 100
}
}, 6000 * 2) <strong>(4)</strong>
Heapdump analysis in Chrome Dev Tools
4
Heapdump analysis in Chrome Dev Tools
5
StrongOps - Memory Profiling and Leak Detection
A nasty one ! (memory leak)
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

Weitere ähnliche Inhalte

Andere mochten auch

Machine Learning Streams with Spark 1.0
Machine Learning Streams with Spark 1.0Machine Learning Streams with Spark 1.0
Machine Learning Streams with Spark 1.0
Andrew Minkin
 

Andere mochten auch (6)

Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance Investigations
 
Measuring the Performance of Single Page Applications
Measuring the Performance of Single Page ApplicationsMeasuring the Performance of Single Page Applications
Measuring the Performance of Single Page Applications
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
 
Machine Learning Streams with Spark 1.0
Machine Learning Streams with Spark 1.0Machine Learning Streams with Spark 1.0
Machine Learning Streams with Spark 1.0
 
Measuring Real User Performance in the Browser
Measuring Real User Performance in the BrowserMeasuring Real User Performance in the Browser
Measuring Real User Performance in the Browser
 

Mehr von Shubhra Kar

Mehr von Shubhra Kar (14)

Node Interactive : 7 years, 7 design patterns, will node continue to outshine
Node Interactive : 7 years, 7 design patterns, will node continue to outshineNode Interactive : 7 years, 7 design patterns, will node continue to outshine
Node Interactive : 7 years, 7 design patterns, will node continue to outshine
 
Node.js Frameworks & Design Patterns Webinar
Node.js Frameworks & Design Patterns WebinarNode.js Frameworks & Design Patterns Webinar
Node.js Frameworks & Design Patterns Webinar
 
Ibm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshopIbm_interconnect_restapi_workshop
Ibm_interconnect_restapi_workshop
 
Design patterns talk_node_summit
Design patterns talk_node_summitDesign patterns talk_node_summit
Design patterns talk_node_summit
 
Node summit workshop
Node summit workshopNode summit workshop
Node summit workshop
 
Toronto node js_meetup
Toronto node js_meetupToronto node js_meetup
Toronto node js_meetup
 
Node frameworks talk_hackerdojo
Node frameworks talk_hackerdojoNode frameworks talk_hackerdojo
Node frameworks talk_hackerdojo
 
Connect js nodejs_devops_shubhra
Connect js nodejs_devops_shubhraConnect js nodejs_devops_shubhra
Connect js nodejs_devops_shubhra
 
Connect js nodejs_api_shubhra
Connect js nodejs_api_shubhraConnect js nodejs_api_shubhra
Connect js nodejs_api_shubhra
 
Triangle Node Meetup : APIs in Minutes with Node.js
Triangle Node Meetup :  APIs in Minutes with Node.jsTriangle Node Meetup :  APIs in Minutes with Node.js
Triangle Node Meetup : APIs in Minutes with Node.js
 
Triangle Node.js DevOps
Triangle Node.js DevOpsTriangle Node.js DevOps
Triangle Node.js DevOps
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
OpenSource Node.js API Framework and Server for Enterprise
OpenSource Node.js API Framework and Server for EnterpriseOpenSource Node.js API Framework and Server for Enterprise
OpenSource Node.js API Framework and Server for Enterprise
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 

Kürzlich hochgeladen

Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
Sheetaleventcompany
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 

Kürzlich hochgeladen (20)

Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, YardstickSaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Presentation on Engagement in Book Clubs
Presentation on Engagement in Book ClubsPresentation on Engagement in Book Clubs
Presentation on Engagement in Book Clubs
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 

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 &gt; nextMBThreshold) { <strong>(3)</strong> heapdump.writeSnapshot() nextMBThreshold += 100 } }, 6000 * 2) <strong>(4)</strong>
  • 4. Heapdump analysis in Chrome Dev Tools 4
  • 5. Heapdump analysis in Chrome Dev Tools 5
  • 6. StrongOps - Memory Profiling and Leak Detection
  • 7. 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/ 8