Originally from https://jira.appcelerator.org/browse/TIMOB-13664:
You can find this module here : https://github.com/ChrOnOs83/TiModuleAndroidGC
Then, we decided to use your files and made it as simple as possible. We finally got a unique app.js file with this content :
When you run this code on your Android Device, you should press many times on the "GC" button, because garbage collector may not clean your ressources each time...
If GC has be done correctly, the second button press will fail, because the label is not here anymore.
If you add the label to the view, and then change its title, no problem
If you create the label in the event listener, no problem
If you makes a reference to a global variable (without the var keyword for example), it works
If you put the function in a CommonJS module, the same rules apply.
So... Titanium objects created in a function (all the Ti.something) may be killed by garbage collector at any time if they are not attached to a view/window, or declared as global var.