by

TiShadow clean-up for Alloy

TiShadow is a great tool for speeding up app development. It allows you to push code to test devices within seconds. But running TiShadow for some time, it will crash. This is because the TiShadow app leaves existing windows open when you push a new bundle of the app. So after some time, you’ll run out of memory.

Update: Not needed anymore now TiShadow cleans up itself.

This behavior is documented and  a solution for both plain and Alloy apps is provided by David. However, I’ve made a few improvements to the alloy.jmk file I like to share:

  • No need to alter your index.js anymore. It just assumes to find a window as the root view of your index-controller. If you need to do further clean-up, like closing additional windows, just add an event listener to the window’s close event.
  • The code will no longer be injected in production deployments.
  • The code will not throw errors anymore when you run it over the simulator instead of TiShadow. Even while they were caught in the original code, the debugger still breaks.