Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

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

Transcript of Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks

Your  Apps  are  Leaking:    App  Profiling  and  More  

Rick  Blalock  

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

3

Common Javascript Leaks

4

Anti-Patterns

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

Global objects will always hang

around

5

Anti-Patterns

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

What about doing something like:

someNameSpace.win = null;

6

Anti-Patterns

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

This is still not ideal

7

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

Don’t Do This!

8

Performance

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

10

Mass Includes

Avoid including large amounts of files in app.js.

Include files as you need them.

11

Mass Includes

12

Mass Includes

13

XCode’s Instruments

14

Brief Overview Living���Live objects using resources

Transitory Objects that have been collected

Overall The sum of both columns above

15

Brief Overview

Filter by these keywords to help find issues:

proxy Ti TiUI

16

Demo