×
Copy
Open
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slide 1
Slide 1 text
Andrew Duncan Managing Director, SwarmOnline Member No. 149387 @andrewduncan
[email protected]
© 2015 SwarmOnline
Slide 2
Slide 2 text
1. Memory Management 2. Tools of the trade MEMORY LEAK HEALTH CHECK Our Quest to Diagnose & Cure © 2015 SwarmOnline
Slide 3
Slide 3 text
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
Slide 4
Slide 4 text
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
Slide 5
Slide 5 text
YES • Garbage Collection NO • Coding Mishaps DOESN’T THIS GET HANDLED FOR ME? © 2015 SwarmOnline
Slide 6
Slide 6 text
WHAT TOOLS DO WE HAVE © 2015 SwarmOnline
Slide 7
Slide 7 text
CHROME & DEVELOPER TOOLS •Task Manager •Timeline •Profiles © 2015 SwarmOnline
Slide 8
Slide 8 text
TASK MANAGER © 2015 SwarmOnline
Slide 9
Slide 9 text
•1st round of testing •Instantaneous view of memory •Useful for monitoring changes over small periods of time TASK MANAGER © 2015 SwarmOnline
Slide 10
Slide 10 text
TIMELINE © 2015 SwarmOnline
Slide 11
Slide 11 text
• 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
Slide 12
Slide 12 text
PROFILES © 2015 SwarmOnline
Slide 13
Slide 13 text
PROFILES •Identify increase in objects •Do comparison © 2015 SwarmOnline
Slide 14
Slide 14 text
RECORD HEAP ALLOCATIONS © 2015 SwarmOnline
Slide 15
Slide 15 text
RECORD HEAP ALLOCATIONS © 2015 SwarmOnline
Slide 16
Slide 16 text
N.B. • Memory is skewed just by having Chrome Developer Tools open • Observer Effect © 2015 SwarmOnline
Slide 17
Slide 17 text
OTHER BROWSER TOOLS All of these browsers have tools that can be used to monitor memory • Internet Explorer • Safari • Firefox © 2015 SwarmOnline
Slide 18
Slide 18 text
INTERNET EXPLORER DEVELOPER TOOLS © 2015 SwarmOnline
Slide 19
Slide 19 text
SAFARI FOR DEVELOPERS © 2015 SwarmOnline
Slide 20
Slide 20 text
FIREFOX DEVELOPER © 2015 SwarmOnline
Slide 21
Slide 21 text
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
Slide 22
Slide 22 text
TASK MANAGER & WINDOWS TOOLS Pipe data out to CSV for charting © 2015 SwarmOnline
Slide 23
Slide 23 text
AUTOMATE MEMORY MONITORING How do we do this? • Virtual Machines • Auto snapshot every X minutes • Reduce Observer Effect • Graph your results © 2015 SwarmOnline
Slide 24
Slide 24 text
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
Slide 25
Slide 25 text
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
Slide 26
Slide 26 text
FINAL THOUGHTS • If all else fails… • Or in extreme circumstances…rm -rf* © 2015 SwarmOnline
Slide 27
Slide 27 text
Andrew Duncan Managing Director, SwarmOnline @andrewduncan
[email protected]
© 2015 SwarmOnline