【发布时间】:2016-06-20 23:32:09
【问题描述】:
我有一个带有窗口的 .js 文件,然后我将所有布局添加到此窗口。
first.js
var Win = Ti.UI.CreateWindow({
backgroundColor : 'white'
});
Win.open();
secun.js
var View = Ti.UI.createView({
height : Ti.UI.SIZE,
width : deviceWidth,
backgroundColor : 'white'
});
Ti.UI.CurrentWindow.add(View);
var label = Ti.UI.createLabel({
text : "Test",
color : 'white',
height : deviceHeight * 0.090,
width : deviceWidth,
backgroundColor : 'transparent',
textAlign : 'center',
font : {
fontSize : deviceHeight * 0.0285,
fontWeight : 'normal'
}
});
View.add(label);
要删除我制作的视图,如下所示:
Ti.UI.CurrentWindow.remove(View);
当我到期时,视图和标签占用的内存被释放了还是需要做其他事情来释放手机内存?就像将变量设置为 null 这样就不再关联 Ti 对象并且可以被垃圾收集器清理?
在我的项目中将变量设为 null 的问题在于,某些变量是在函数内部创建的,然后在该函数外部不可用。
【问题讨论】:
标签: javascript android ios garbage-collection titanium