Created
May 20, 2011 17:23
-
-
Save rblalock/983360 to your computer and use it in GitHub Desktop.
Memory Release example1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Will release child objects | |
*/ | |
var mypage = function() { | |
var win = Ti.UI.createWindow(), | |
table = Ti.UI.createTableView(), | |
label = Ti.UI.createLabel(); | |
win.add(table); | |
win.add(label); | |
return win; | |
}; | |
var newpage = new mypage(); | |
newpage.open(); | |
newpage.close(); | |
newpage = null; | |
/** | |
* Will not release child objects since they are referenced elsewhere; must do it manually | |
*/ | |
var mypage = (function() { | |
var com = {}; | |
com.win = Ti.UI.createWindow(); | |
com.table = Ti.UI.createTableView(); | |
com.label = Ti.UI.createLabel(); | |
com.win.add(com.table); | |
com.win.add(com.label); | |
return com; | |
})(); | |
mypage.win.open(); | |
mypage.win.close(); | |
mypage.win = null; | |
// Even though the window has been closed and destroyed, the table and label still exist | |
Ti.API.info(mypage.table); | |
Ti.API.info(mypage.label); | |
// you'll need to also do | |
mypage.table = null; | |
mypage.label = null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment