Titanium SDK版本:1.7.0 iPhone SDK版本:4.2
我正在开发一个iOS应用程序,我监控每个窗口的内存使用情况并且每个屏幕都会不断减少。
一般消耗内存是什么?我使用视图,表格和XHR数据。
如何在每个窗口上释放内存/减少使用量?
感谢所有输入!
答案 0 :(得分:0)
考虑到您正在处理将JavaScript转换为Objective-C并且无法在不使用模块的情况下编写本机解决方案,您可以通过将窗口变量设置为null
(myJsWindowVar = null;
)来开始,或使用delete
(delete myJsWindowVar;
)删除这些变量。我个人认为将变量设置为null
将更好地转换为建议的Objective-C最佳实践,即设置指针引用null
并防止孤立对象悬空。
答案 1 :(得分:0)
确保关闭未使用的窗口并清除我们对应用程序中不再需要的本机对象的任何引用。
// create a window object
var aWindow = Ti.UI.createWindow();
var aLabel = Ti.UI.createLabel({ text : "Hey" });
aWindow.add(aLabel);
aWindow.open();
// done with window
aWindow.close();
aWindow = null;
aLabel.null;
从Appcelerator Codestrong会议中查看this presentation以获取更多详细信息。