Debug memory leaks with XCode Instruments

Apple_Instruments_IconUsing Appcelerator doesn’t mean you don’t have to take care of memory leaks. Odds are there is at least one leak in your app right now. Relatively unknown is that this can be easily detected with some XCode Instruments. I’ll show you how.


Run your app from Titanium Studio or CLI in the Simulator or on a device. Then launch XCode and go to Xcode > Open Developer Tool > Instruments

Schermafbeelding 2014-01-20 om 10.21.46

Now choose Allocations

Schermafbeelding 2014-01-20 om 10.21.57

In the drop down menu go to Attach to Process and select your app in the System section if it runs in Simulator or on the device listed. The list is not alphabetically sorted so keep looking :)

Schermafbeelding 2014-01-20 om 10.23.05


Filter on TiUI or Proxy and you will see the Titanium objects appearing while navigating through your app. The objects should be disappearing when they are no longer active. Each label will appear as a TiUILabel so you won’t know which label. Try to debug one window at a time so you get a better idea where the leak is exactly.

Schermafbeelding 2014-01-20 om 10.23.41


Be aware of the fact that when you are running in the Simulator the amount of memory is equal to your Mac. Garbage collection might take a while because of that. Unfortunately there is no way to manually trigger the garbage collector. A workaround is hooking the Allocation instrument up to a device with little memory.

Also see this talk on leaking apps at Codestrong 2012: