Top Banner
Your Apps are Leaking: App Profiling and More Rick Blalock
16

Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

Jul 16, 2015

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

Your  Apps  are  Leaking:    App  Profiling  and  More  

Rick  Blalock  

Page 2: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

2

What We’ll Cover

- Common Javascript leaks - Performance - Introduction to XCode Instruments - How to narrow down leaks in your code - Introduction to DDMS (if time allows)

Project Files: https://github.com/rblalock/codestrong2011_appleak

Page 3: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

3

Common Javascript Leaks

Page 4: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

4

Anti-Patterns

Don’t assume win.close()���releases memory!

Global objects will always hang

around

Page 5: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

5

Anti-Patterns

Even setting the window to null will not release the global objects

What about doing something like:

someNameSpace.win = null;

Page 6: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

6

Anti-Patterns

If you insist on having objects in some global namespace then do this:

This is still not ideal

Page 7: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

7

Local variables referenced inside a global event will cause a memory leak every time

Don’t Do This!

Page 8: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

8

Performance

Page 9: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

9

Needless Execution

Don’t execute code until you need it

The biggest performance hit will be on Android

No point in processing something that isn’t going to be used yet

Especially bad when done in several included files in app.js

Page 10: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

10

Mass Includes

Avoid including large amounts of files in app.js.

Include files as you need them.

Page 11: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

11

Mass Includes

Page 12: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

12

Mass Includes

Page 13: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

13

XCode’s Instruments

Page 14: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

14

Brief Overview Living���Live objects using resources

Transitory Objects that have been collected

Overall The sum of both columns above

Page 15: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

15

Brief Overview

Filter by these keywords to help find issues:

proxy Ti TiUI

Page 16: Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

16

Demo