Issue
"Destroying a parent object (setting it to null) will destroy any child objects as long as no other references to those child objects exist. Consider the following code snippet to get a feel for the specifics:"
Tested on
iOS 5 simulator
Test Case 1
var win = Titanium.UI.createWindow({
title: 'Main',
exitOnClose: true,
fullscreen: false,
navBarHidden: false,
backgroundColor: 'gray'
});
var button = Ti.UI.createButton({
// parameters go here...
title: 'deletes the view and its proxy,\nbut not the button!',
backgroundColor: 'red'
});
var view = Ti.UI.createView({
// some parameters here...
borderRadius:10,
top: 15
});
view.add(button);
win.add(view);
win.addEventListener('click', function(){
// ... later
win.remove(view); // view & button still exist
view = null; //deletes the view and its proxy, but not the button!
});
win.open();
So Having button set to null do get released (as seen in Instruments).
Test Case 2
var win = Titanium.UI.createWindow({
title: 'Main',
exitOnClose: true,
fullscreen: false,
navBarHidden: false,
backgroundColor: 'gray'
});
var button = Ti.UI.createButton({
// parameters go here...
title: 'deletes the view and its proxy,\nbut not the button!',
backgroundColor: 'red'
});
var view = Ti.UI.createView({
// some parameters here...
borderRadius:10,
top: 15
});
view.add(button);
win.add(view);
win.addEventListener('click', function(){
// ... later
win.remove(view); // view & button still exist
view = null; // deletes the view and its proxy, but not the button!
button = null;//do get released
});
win.open();
Additional info
Test results and its corresponding screenshots:
TestCase 1 - Button not being set > InstrumentsProxies_2.1.0_TestCase1_a.jpg
TestCase 1 - Button set to null > InstrumentsProxies_2.1.0_TestCase1_b.jpg
TestCase 2 - Button not being set > InstrumentsProxies_2.1.0_TestCase2_a.jpg
TestCase 2 - Button set to null > InstrumentsProxies_2.1.0_TestCase2_b.jpg
Wiki Link
https://wiki.appcelerator.org/display/guides/Managing+Memory+and+Finding+Leaks#ManagingMemoryandFindingLeaks-WhenTitaniumreleasesmemory
Test case 1. is invalid. The button should still exist because there is still a reference to it;
var button
.Test case is invalid. The button is managed correctly because it still has a reference.
@Stephen Does that mean nulling that proxy should be done explicitly? i.e. button = null;
Yes. Please do not reopen tickets to ask a question.
Closing issue; requires no further validation. Please see Opie's description on the companion Android ticket for any more specific details.