SlideShare a Scribd company logo
Your	
  Apps	
  are	
  Leaking:	
  	
  
App	
  Profiling	
  and	
  More	
  

            Rick	
  Blalock	
  
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


                                                                        2
Common Javascript Leaks

                          3
Anti-Patterns

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



          Global
       objects will
       always hang
         around	


                                4
Anti-Patterns

What about doing
something like:	

someNameSpace.win = null;	





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

                                                        5
Anti-Patterns

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





           This is still not ideal	

                                          6
Don’t Do
                                              This!	





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


                                                         7
Performance	

                 8
Needless Execution	



No point in
                    The biggest       Especially bad
processing
                    performance hit   when done in
something that
                    will be on        several included
isn’t going to be
                    Android	

        files in app.js	

used yet	


Don’t execute code until you need it	

                   9
Mass Includes	


Avoid including large amounts of
          files in app.js.	


Include files as you need them.	



                                    10
Mass Includes	





                   11
Mass Includes	





                   12
XCode’s Instruments	

                         13
Brief Overview	

Living
Live objects using resources	


Transitory	

Objects that have been collected	


Overall	

The sum of both columns above	




                                      14
Brief Overview	

Filter by these keywords to
help find issues:	


proxy	

Ti	

TiUI	





                               15
Demo	

          16

More Related Content

Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks