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
Droid Razr 2.3.5
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 DDMS).
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 > DDMS_Droid_2.1.0_TestCase1_a.jpg
TestCase 1 - Button set to null > DDMS_Droid_2.1.0_TestCase1_b.jpg
TestCase 2 - Button not being set > DDMS_Droid_2.1.0_TestCase2_a.jpg
TestCase 2 - Button set to null > DDMS_Droid_2.1.0_TestCase2_b.jpg
Wiki Link
https://wiki.appcelerator.org/display/guides/Managing+Memory+and+Finding+Leaks#ManagingMemoryandFindingLeaks-WhenTitaniumreleasesmemory
This issue is invalid. The reason why is actually called out in the description: "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:" Key phrase here is: "as long as no other references to those child objects exist". A reference is anything that maintains a reference to the object (both the "button" variable and the view object keep their own references. Following that line of thought, setting view to null frees one of those references but there is still another ("var button").
Address key notes in: TIDOC-608
Closing ticket as invalid with reference to the above comments.