0
我有一个窗口的.js文件,然后我所有的布局添加到这个窗口。从钛内存中删除VAR对象
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);
当我由于这一点,由View和标签占用的内存是发布还是需要做其他事情来释放手机内存?像设置变量为空,所以不再是关联的Ti对象,并可以通过垃圾收集器清理?
在我的项目中,将变量沸腾到null的问题在于,一些变量是在函数内部创建的,然后在函数外部不可用。
又如何我是否可以释放已创建并需要在我的函数的其他位置访问的变量的内存? –
@Manuel_Rodrigues,您可以在删除该视图之前使用视图的'removeAllChildren()'方法。 http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.View-method-removeAllChildren – Swanand