I have an app where there is a window. In that window there is a view and that view has a button in it. I want to close the window and free the memory which was being used by the window.
So, can we create a method which will iterate through a window and get all the controls so that we can make the elements like button in a view to null after it is used.
I am assuming that you are trying to free memory and want to prevent memory leaks,you can do it this way
//create a window
var win = Titanium.UI.createWindow({
});
win.open();
//create a view
var view = Titanium.UI.createView({
});
win.add(view)//add view to window
//create button
var button = Titanium.UI.createButton({
});
view.add(button);//add button to view
//similarly add what ever you want according to your requirement
//this will free memory
win.remove(view); // view & button still exist
view = null; // deletes the view and its proxy, but not the button!
button = null;//deletes the button and delete all the elements what ever you have added
//if you have inserted views/tableviewrows/buttons and other elements into an array then nullifying it after their use like this
var SampleArray = [];
//added views,rows etc...to this SampleArray
SampleArray = null;
For further reference follow this link for Managing Memory and Finding Leaks : https://wiki.appcelerator.org/display/guides/Managing+Memory+and+Finding+Leaks#ManagingMemoryandFindingLeaks-WhenTitaniumreleasesmemory