Titanium 中的内存管理 android
memory management in Titanium android
我不确定这是做什么的。
例如:
var myView = Ti.UI.createView({
height : "10.8%",
top : 0,
width : "30%",
right : 0,
zIndex : 100
});
var myLabel =Ti.UI.createLabel({
text : (local).toString().toUpperCase(),
color : "#444444",
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
font : {
fontSize : deviceWidth * 0.03,
fontFamily : "Dosis-SemiBold"
},
backgroundColor : "transparent",
});
myView.add(myLabel);
在这种情况下,我已将标签添加到我的视图中。
如果我使用以下方法从视图中删除标签:myView.removeAllChildren();
,标签访客从视图中删除,但标签会被 GC 从内存中删除,或者由于我确实需要将标签设置为空?
您的标签仍将保留在内存中,事实上您可以将其添加回视图以实际看到它仍然存在。
您必须将该变量置空才能将其从内存中完全删除。
让我引用 docs
Problems arise when you leave references to objects that you no longer need. You can remove references by setting variables and objects to null when you no longer need them. This includes both variables and objects you create to represent your app's business logic, but also objects that represent Titanium components such as Views or Images.
好好读书:)
我不确定这是做什么的。
例如:
var myView = Ti.UI.createView({
height : "10.8%",
top : 0,
width : "30%",
right : 0,
zIndex : 100
});
var myLabel =Ti.UI.createLabel({
text : (local).toString().toUpperCase(),
color : "#444444",
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
font : {
fontSize : deviceWidth * 0.03,
fontFamily : "Dosis-SemiBold"
},
backgroundColor : "transparent",
});
myView.add(myLabel);
在这种情况下,我已将标签添加到我的视图中。
如果我使用以下方法从视图中删除标签:myView.removeAllChildren();
,标签访客从视图中删除,但标签会被 GC 从内存中删除,或者由于我确实需要将标签设置为空?
您的标签仍将保留在内存中,事实上您可以将其添加回视图以实际看到它仍然存在。
您必须将该变量置空才能将其从内存中完全删除。
让我引用 docs
Problems arise when you leave references to objects that you no longer need. You can remove references by setting variables and objects to null when you no longer need them. This includes both variables and objects you create to represent your app's business logic, but also objects that represent Titanium components such as Views or Images.
好好读书:)