开发者

Appcelerator. Handle memory usage. Best practice

开发者 https://www.devze.com 2023-03-16 08:09 出处:网络
Titanium SDK version: 1.7.0 iPhone SDK version: 4.2 I am developing an iOS app and I mo开发者_高级运维nitor the memory usage for each window And it keeps decreasing for every screen.

Titanium SDK version: 1.7.0 iPhone SDK version: 4.2

I am developing an iOS app and I mo开发者_高级运维nitor the memory usage for each window And it keeps decreasing for every screen.

  1. What is consuming memory in general? I use views, tables and XHR data.

  2. How can I release memory / decrease usage on each window?

Thankful for all input!


Considering you are dealing with JavaScript being translated to Objective-C and can't necessarily write a native solution without using modules you could start by setting window variables to null (myJsWindowVar = null;), or delete those variables using delete (delete myJsWindowVar;). Personally I think setting variables to null will better translate to the suggested Objective-C best practice which is to set a pointer reference to null and prevent orphaned objects from hanging around.


Make sure you close unused windows and clear our any references to native objects you no longer need in the app.

// 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;

Check out this presentation from the Appcelerator Codestrong conference for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号