Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Memory Leak Health Check

Memory Leak Health Check

6d0ac0a0024c8bb4ba9cb3eefaabc3f2?s=128

Andrew Duncan

May 10, 2015
Tweet

Transcript

  1. Andrew Duncan Managing Director, SwarmOnline Member No. 149387 @andrewduncan andrew@swarmonline.com

    © 2015 SwarmOnline
  2. 1. Memory Management 2. Tools of the trade MEMORY LEAK

    HEALTH CHECK Our Quest to Diagnose & Cure © 2015 SwarmOnline
  3. WHY IS THIS TOPIC IMPORTANT? • Move to richer /

    interactive applications • More use of JavaScript to achieve this • Single Page Applications • Cross integration of multiple frameworks and technologies • Multiple device types, operating systems and browsers © 2015 SwarmOnline
  4. MEMORY LEAK DEFINITION mem . o . ry leak noun

    COMPUTING noun: memory leak; plural noun: memory leaks a failure in a program to release discarded memory, causing impaired performance or failure. © 2015 SwarmOnline
  5. YES • Garbage Collection NO • Coding Mishaps DOESN’T THIS

    GET HANDLED FOR ME? © 2015 SwarmOnline
  6. WHAT TOOLS DO WE HAVE © 2015 SwarmOnline

  7. CHROME & DEVELOPER TOOLS •Task Manager •Timeline •Profiles © 2015

    SwarmOnline
  8. TASK MANAGER © 2015 SwarmOnline

  9. •1st round of testing •Instantaneous view of memory •Useful for

    monitoring changes over small periods of time TASK MANAGER © 2015 SwarmOnline
  10. TIMELINE © 2015 SwarmOnline

  11. • Monitors memory over time • Sudden drops === GC

    • Look out for two things: • Steady rise in the chart • GC not returning to original memory usage TIMELINE © 2015 SwarmOnline
  12. PROFILES © 2015 SwarmOnline

  13. PROFILES •Identify increase in objects •Do comparison © 2015 SwarmOnline

  14. RECORD HEAP ALLOCATIONS © 2015 SwarmOnline

  15. RECORD HEAP ALLOCATIONS © 2015 SwarmOnline

  16. N.B. • Memory is skewed just by having Chrome Developer

    Tools open • Observer Effect © 2015 SwarmOnline
  17. OTHER BROWSER TOOLS All of these browsers have tools that

    can be used to monitor memory • Internet Explorer • Safari • Firefox © 2015 SwarmOnline
  18. INTERNET EXPLORER DEVELOPER TOOLS © 2015 SwarmOnline

  19. SAFARI FOR DEVELOPERS © 2015 SwarmOnline

  20. FIREFOX DEVELOPER © 2015 SwarmOnline

  21. TASK MANAGER & WINDOWS TOOLS • Record memory usage in

    Perfmon & PsTools (PsList) • Plot and view memory usage over time • In our case 1 hour, 24 hours, 1 week, 1 month PsTools PsList © 2015 SwarmOnline
  22. TASK MANAGER & WINDOWS TOOLS Pipe data out to CSV

    for charting © 2015 SwarmOnline
  23. AUTOMATE MEMORY MONITORING How do we do this? • Virtual

    Machines • Auto snapshot every X minutes • Reduce Observer Effect • Graph your results © 2015 SwarmOnline
  24. HOW TO DO THIS YOURSELF • Strip it back to

    basics • App in container only • Send data but don’t enable parsing • Add in the data package • If your app has multiple parsers for different types of data, enable each data packet individually • Gradually add in your controllers and view • Each view will need tested individually • Create your app with only one view enabled • We run over 30 VM’s with different versions of an app to get as much coverage as possible © 2015 SwarmOnline
  25. HOW TO DO THIS YOURSELF (2) • If you suspect

    something is going wrong • Take snapshot • Run code • Take snapshot • Review differences • Obviously new data (e.g. Ajax requests) are going to skew your results between snapshots © 2015 SwarmOnline
  26. FINAL THOUGHTS • If all else fails… • Or in

    extreme circumstances…rm -rf* © 2015 SwarmOnline
  27. Andrew Duncan Managing Director, SwarmOnline @andrewduncan andrew@swarmonline.com © 2015 SwarmOnline